Skip to content

Remove jQuery from the JavaScript runtime#1006

Merged
tagliala merged 1 commit intomainfrom
chore/remove-jquery
Apr 19, 2026
Merged

Remove jQuery from the JavaScript runtime#1006
tagliala merged 1 commit intomainfrom
chore/remove-jquery

Conversation

@tagliala
Copy link
Copy Markdown
Contributor

@tagliala tagliala commented Apr 6, 2026

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/dispatchEvent and 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.

Comment thread src/utils.js Outdated
Comment thread src/utils.js Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/validators/local/uniqueness.js
Comment thread CHANGELOG.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread CHANGELOG.md Outdated
Comment thread README.md Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread CHANGELOG.md Outdated

## Unreleased

## 24.0.0 / YYYY-MM-DD
Copy link

Copilot AI Apr 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
## 24.0.0 / YYYY-MM-DD

Copilot uses AI. Check for mistakes.
@tagliala tagliala force-pushed the chore/remove-jquery branch from 48f5b9f to 000947a Compare April 19, 2026 10:08
@tagliala tagliala changed the title Chore/remove jquery Remove jQuery from the JavaScript runtime Apr 19, 2026
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.
@tagliala tagliala force-pushed the chore/remove-jquery branch from 000947a to 8e46264 Compare April 19, 2026 10:09
@tagliala tagliala merged commit 1e22209 into main Apr 19, 2026
22 checks passed
@tagliala tagliala deleted the chore/remove-jquery branch April 19, 2026 10:11
@tagliala tagliala mentioned this pull request Apr 19, 2026
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants