Remove jQuery from the JavaScript runtime#1006
Conversation
6615ad6 to
590a4e6
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the runtime jQuery dependency from ClientSideValidations by switching the implementation and public API to native DOM elements, events, and event listeners.
Changes:
- Replace jQuery event binding/unbinding and triggering with native
addEventListener/dispatchEventand internal listener tracking. - Replace the jQuery plugin API (
$.fn.validate,$.fn.isValid, etc.) with DOM-first static APIs (ClientSideValidations.validate/enable/isValid/...). - Update the QUnit test harness and validator tests to use DOM APIs and remove jQuery from the test runner.
Reviewed changes
Copilot reviewed 39 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| vendor/assets/javascripts/rails.validations.js | Compiled sprockets asset updated to a jQuery-free runtime using native DOM/events. |
| test/javascript/views/index.erb | Removes jQuery script include from the QUnit runner page. |
| test/javascript/server.rb | Removes jquery-rails asset serving and switches iframe event dispatch to native events. |
| test/javascript/public/test/validators/uniqueness.js | Migrates uniqueness tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/presence.js | Migrates presence tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/numericality.js | Migrates numericality tests from jQuery to DOM APIs and manual form setup. |
| test/javascript/public/test/validators/length.js | Migrates length tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/inclusion.js | Migrates inclusion tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/format.js | Migrates format tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/exclusion.js | Migrates exclusion tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/confirmation.js | Migrates confirmation tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/acceptance.js | Migrates acceptance tests from jQuery to DOM APIs. |
| test/javascript/public/test/validators/absence.js | Migrates absence tests from jQuery to DOM APIs. |
| test/javascript/public/test/validateElement.js | Migrates element validation integration tests from jQuery to DOM/events. |
| test/javascript/public/test/settings.js | Replaces jQuery-based submit hijacking with native submit handling and iframe creation. |
| test/javascript/public/test/form_builders/validateForm.js | Migrates form validation integration tests to DOM APIs and the new public API. |
| test/javascript/public/test/callbacks/formPass.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/formFail.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/formBefore.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/formAfter.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/elementPass.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/elementFail.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| test/javascript/public/test/callbacks/elementBefore.js | Migrates callback tests to DOM APIs and fixes validator key typo while updating behavior. |
| test/javascript/public/test/callbacks/elementAfter.js | Migrates callback tests to DOM APIs and updates callback arg expectations. |
| src/validators/local/uniqueness.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/numericality.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/length.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/format.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/exclusion_inclusion.js | Updates local validator signatures to accept DOM elements. |
| src/validators/local/confirmation.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/acceptance.js | Updates local validator signature to accept a DOM element. |
| src/validators/local/absence_presence.js | Updates local validator signatures to accept DOM elements. |
| src/utils.js | Adds DOM helpers (getDOMElements, isFormElement, isInputElement, isVisible). |
| src/index.js | Introduces DOM-first public API and switches validation flow to native events. |
| src/events.js | Adds listener bookkeeping utilities (bind/clear/dispatch) replacing jQuery. |
| src/core.js | Reworks core runtime to bind native events and remove jQuery assumptions. |
| rollup.config.mjs | Removes jQuery externals/globals from bundling configuration. |
| README.md | Documents removal of jQuery dependency and provides a migration guide + updated examples. |
| package.json | Removes jQuery peer dependency. |
| dist/client-side-validations.js | Rebuilt UMD bundle without jQuery dependency. |
| dist/client-side-validations.esm.js | Rebuilt ESM bundle without jQuery dependency. |
| CHANGELOG.md | Notes unreleased breaking changes and the jQuery removal. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 43 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 43 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 43 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5aaad39 to
48f5b9f
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 42 out of 45 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| ## Unreleased | ||
|
|
||
| ## 24.0.0 / YYYY-MM-DD |
There was a problem hiding this comment.
The 24.0.0 changelog entry still uses a YYYY-MM-DD placeholder. Before releasing, replace it with the actual release date, or move these bullets under the Unreleased section until the date is known.
| ## 24.0.0 / YYYY-MM-DD |
48f5b9f to
000947a
Compare
Drop the remaining jQuery dependency from the published JavaScript runtime and move the validation flow to native DOM APIs. ClientSideValidations.enable(), validate(), isValid(), disable(), and reset() now work with DOM elements and DOM collections instead of jQuery objects. Validation callbacks and local validators also receive native nodes, which keeps custom integrations aligned with the new runtime surface. Replace jQuery event wiring with native CustomEvent dispatch and addEventListener hooks. Update visibility checks, dataset state, uniqueness handling, and helper utilities so the runtime can traverse forms and inputs without jQuery while preserving the existing validation behavior. Refresh the QUnit suite to build fixtures with plain DOM methods and assert against native events and callback arguments. Regenerate the bundled assets, switch the test harness to a neutral QUnit CDN, and remove jquery from the package metadata. Document the 24.0.0 breaking changes in the README and changelog, and bump the gem and npm package versions for the release.
000947a to
8e46264
Compare
Drop the remaining jQuery dependency from the published JavaScript
runtime and move the validation flow to native DOM APIs.
ClientSideValidations.enable(), validate(), isValid(), disable(), and
reset() now work with DOM elements and DOM collections instead of
jQuery objects. Validation callbacks and local validators also receive
native nodes, which keeps custom integrations aligned with the new
runtime surface.
Replace jQuery event wiring with native CustomEvent dispatch and
addEventListener hooks. Update visibility checks, dataset state,
uniqueness handling, and helper utilities so the runtime can traverse
forms and inputs without jQuery while preserving the existing
validation behavior.
Refresh the QUnit suite to build fixtures with plain DOM methods and
assert against native events and callback arguments. Regenerate the
bundled assets, switch the test harness to a neutral QUnit CDN, and
remove jquery from the package metadata.
Document the 24.0.0 breaking changes in the README and changelog, and
bump the gem and npm package versions for the release.