Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

mrujs

KonnorRogers8.1kMIT1.0.2TypeScript support: included

UJS for modern javascript.

ujs, rails

readme

Purpose

To provide an upgrade path for those looking to retain the features of rails-ujs, but using a currently maintained library written in Typescript and using modern features like MutationObservers and fetch.

Check out the docs

The official docs can be found here:

https://mrujs.netlify.app

Working on mrujs locally

  1. Clone the repo
git clone https://github.com/ParamagicDev/mrujs
cd mrujs
  1. Install packages
pnpm install

View Dev Server

pnpm run start

Run tests

pnpm test

Rails

There is also a Rails dummy app attached in this repo for testing.

Installation

Top level:

bundle install

Starting

Must be run within the test/rails/dummy directory.

cd test/rails/dummy && bundle exec rails server

Tests

From any where outside of the test/rails/dummy directory:

bundle exec rake test

Docs

Docs are located in /docs and use Bridgetown + Netlify.

To start the docs server do the following:

cd docs && bundle install && bin/bridgetown start

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.0.2 (2024-08-16)

1.0.1 (2024-08-12)

Bug Fixes

  • dont try to submit links that are alt / ctrl clicked (#217) (7aea28b)

1.0.0 (2023-05-25)

⚠ BREAKING CHANGES

  • prefetch now only takes a url
  • morph now affects the full <html> document and not just document.body

Features

  • add ujs:beforeMorph and ujs:afterMorph (69bb10c)

Bug Fixes

  • update default Content-Type to reflect the one used by cable_ready: text/vnd.cable-ready.json (#209) (3826981)
  • BREAKING CHANGE: prefetch now only takes a url (#200) (86ec3dd), closes #200

0.10.1 (2022-04-06)

0.10.0 (2022-04-06)

Features

  • Add data-ujs-morph-root for morphdom rendering (#187) (cdf47da)

0.9.0 (2022-03-13)

Features

  • allow alternate rendering techniques (#186) (ec4d0b6)

0.8.4 (2022-02-21)

Bug Fixes

  • confirm:complete now fires appropriately (#183) (322b209)

0.8.3 (2022-01-27)

  • Fix typings for main entrypoint and plugins entrypoint

0.8.2 (2022-01-27)

Bug Fixes

0.8.1 (2022-01-27)

0.8.0 (2022-01-22)

0.7.4 (2021-12-26)

0.7.3 (2021-12-26)

Bug Fixes

  • shoelace plugin uses target instead of currentTarget" (17eeb36)

0.7.2 (2021-12-02)

Bug Fixes

  • submit events no longer need details. (#172) (4af9efc)

0.7.1 (2021-11-26)

Bug Fixes

  • CSRF Tokens not attaching on non-GET requests (#166) (3bac5af)

0.7.0 (2021-11-23)

Changed

Bug Fixes

0.6.1 (2021-11-21)

Features

0.6.0 (2021-10-30)

  • Changed

    • match => matches
    • findFormElements => formElements
    • refresh => refreshCSRFTokens()
    • getToken => csrfToken()
    • getParam => csrfParam()
    • querySelectors got a revamp and now are the same as in Rails-UJS
  • Removed

    • ajax()
    • serializeElement()
    • getData()
    • setData()
    • handleRemote()
    • href()
    • isCrossDomain()
    • loadCSPNonce()
    • formSubmitButtonClick()
    • AsyncConfirm()
    • config object (querySelectors removed, mimeType now top level on the Mrujs object)
  • Modified

    • CSRFProtection takes a Request object instead of an XmlHttpRequest
  • Added

    • toArray
    • $ (document.querySelectorAll)
    • delegate (backwards compatibility)
    • fileInputSelector
  • Aliases

    • fire === dispatch (dispatch returns the event, fire returns if it was prevented)

0.5.11 (2021-10-28)

0.5.10 (2021-10-26)

Bug Fixes

0.5.9 (2021-10-17)

Bug Fixes

  • jsErb headers and submit-event polyfill (#154) (a9a7ea0)

0.5.8 (2021-10-16)

0.5.7 (2021-10-16)

Features

Bug Fixes

0.5.6 (2021-10-15)

Bug Fixes

  • allow remote submissions on formInputSelectors (#145) (fb57a39)

0.5.5 (2021-10-09)

Bug Fixes

0.5.4 (2021-10-04)

Bug Fixes

0.5.3 (2021-09-27)

0.5.2 (2021-09-27)

Bug Fixes

0.5.1 (2021-09-25)

Features

Bug Fixes

  • use animation frames when nodes are added (#135) (a2e5a10)

0.5.0 (2021-09-24)

Bug Fixes

0.5.0-beta.5 (2021-09-20)

Bug Fixes

  • element disabling aligned with rails-ujs (#129) (81b7da1)

0.5.0-beta.4 (2021-09-20)

Features

0.5.0-beta.3 (2021-09-18)

Bug Fixes

0.5.0-beta.2 (2021-09-17)

Bug Fixes

0.5.0-beta.1 (2021-09-17)

0.5.0-beta.0 (2021-09-17)

Bug Fixes

0.4.21 (2021-09-14)

0.4.20 (2021-09-14)

0.4.19 (2021-09-14)

0.4.18 (2021-09-13)

0.4.17 (2021-09-13)

0.4.16 (2021-09-13)

0.4.15 (2021-09-13)

0.4.14 (2021-09-13)

Features

Bug Fixes

0.4.13 (2021-09-08)

Features

0.4.12 (2021-09-07)

Bug Fixes

  • Check if submit-event polyfill exists (#114) (75baf0f)

0.4.11 (2021-09-07)

0.4.10 (2021-09-05)

0.4.9 (2021-09-05)

0.4.8 (2021-09-05)

0.4.7 (2021-09-05)

0.4.6 (2021-09-05)

0.4.5 (2021-09-05)

0.4.4 (2021-09-05)

Breaking Changes

CableCar plugin has been moved into its own seperate entrypoint at "mrujs/plugins"

0.4.3 (2021-09-02)

Bug Fixes

0.4.2 (2021-08-29)

Features

Bug Fixes

  • Fixes a bug in the mutation observer not checking attributes (#108) (7612aba)

0.4.1 (2021-08-26)

0.4.0 (2021-08-26)

BREAKING CHANGES

  • API Changes:
    • FetchResponse.responseHtml -> FetchResponse.html()
    • FetchResponse.responseText -> FetchResponse.text()
    • FetchResponse.responseJson -> FetchResponse.json()
    • responses are no longer stored so they cannot be consumed twice.
    • (#103) (6ff3a6f)

Features

0.3.8-beta.0 (2021-08-24)

0.3.7 (2021-08-20)

Bug Fixes

  • CableCar mime types more permissive. (#101) (1d13a95)

0.3.7-beta.6 (2021-08-11)

0.3.7-beta.5 (2021-08-11)

0.3.7-beta.4 (2021-08-11)

0.3.7-beta.3 (2021-08-11)

Features

0.3.7-beta.2 (2021-08-09)

Bug Fixes

  • mrujs.fetch now properly accepts Request objects.

0.3.7-beta.1 (2021-08-09)

Features

  • mrujs.fetch can now dispatch events! (#91) (92a4e76)

Bug Fixes

  • GET requests now properly submit URLSearchParams (#91) (92a4e76)

0.3.7-beta.0 (2021-08-09)

Bug Fixes

  • GET requests now properly submit URLSearchParams (#91) (92a4e76)

0.3.6 (2021-07-25)

0.3.5 (2021-07-25)

  • Adds button[data-disable] to querySelectors

0.3.4 (2021-07-25)

Features

  • Adds mrujs.enableElement and mrujs.disableElement top level. (#87) (e898a5a)

  • Adds data-ujs-navigateto opt out of the navigation adapter. (#87) (e898a5a)

Fixes

  • Fixes needing [data-remote] on buttons (#87) (e898a5a)

0.3.3 (2021-07-22)

Features

0.3.2 (2021-07-18)

Bug Fixes

  • allow for cancelling nav adapter (#84) (353a977)

  • Use morphdom if redirecting to the current URL (#84) (353a977)

0.3.1 (2021-07-17)

0.3.0 (2021-07-17)

0.3.0-beta.31 (2021-07-17)

Features

Fixes

0.3.0-beta.29 (2021-07-16)

Bug Fixes

0.3.0-beta.28 (2021-07-16)

Features

Add a initialize and observerCallback hook

0.3.0-beta.27 (2021-07-07)

Features

Bug Fixes

  • event listeners now attach properly when attributes change (#66) (39632a2)
  • json matching (6ca5116)

0.3.0-beta.26 (2021-07-03)

Features

  • cablecar: allow custom default MimeTypes (#62) (606330e)

0.3.0-beta.23 (2021-07-03)

Features

0.3.0-beta.21 (2021-07-01)

Bug Fixes

  • addedNodesObserver properly observes attributes now (#57) (bb52891)

0.3.0-beta.21 (2021-07-01)

Bug Fixes

  • addedNodesObserver properly observes attributes now (#57) (bb52891)

0.3.0-beta.19 (2021-06-30)

Features

  • PLUGINS!!

0.3.0-beta.18 (2021-06-30)

Features

  • Custom MimeType registering

Fixes

  • isJson checks on FetchResponse are now more inclusive.

0.3.0-beta.17 (2021-06-27)

Features

Fixes

  • data-confirm event ordering on mutation observers
  • confirm ordering on elements (0324b54)

0.3.0-beta.16 (2021-06-24)

Features

Reverts

  • Revert "chore(release): 0.3.0" (dacf18e)

0.3.0-beta.15 (2021-06-17)

0.3.0-beta.14 (2021-06-13)

Features

Bug Fixes

0.3.0-beta.14 (2021-06-13)

Bug Fixes

  • Disabling of buttons now works as originally intended.

0.3.0-beta.11 (2021-06-12)

Bug Fixes

0.3.0-beta.10 (2021-06-11)

Bug Fixes

0.3.0-beta.8 (2021-06-10)

0.3.0-beta.8 (2021-06-09)

0.3.0-beta.2 (2021-06-08)

Fixes

  • Fix raising errors on forms that don't redirect on success.

0.3.0-beta.1 (2021-06-08)

Features

0.2.0 (2021-06-05)

Deprecation Warning

  • data-response="json" has been changed to data-type="json" to align with UJS.

Bug Fixes

Features

0.1.2 (2021-05-28)

Bug Fixes

  • dont fire turbolinks if not redirected (d4d04dd)

0.1.1 (2021-05-28)

0.1.0 (2021-05-27)

0.1.0-beta.14 (2021-05-23)

0.1.0-beta.13 (2021-05-23)

0.1.0-beta.11 (2021-05-23)

0.1.0-beta.10 (2021-05-23)

Features

0.1.0-beta.9 (2021-05-17)

0.1.0-beta.8 (2021-05-17)

0.1.0-beta.7 (2021-05-10)

0.1.0-beta.6 (2021-05-09)

0.1.0-beta.5 (2021-05-09)

0.1.0-beta.4 (2021-05-08)

0.1.0-beta.3 (2021-05-08)

Features

  • add stopImmediatePropagation to method (19da4f7)

0.1.0-beta.2 (2021-05-08)

Features

0.0.6 (2021-05-03)

0.0.5 (2021-05-03)

0.0.2 (2021-05-01)