Skip to content

Remove jQuery dependency

Marc-André Lafortune edited this page Mar 7, 2017 · 8 revisions

Removing jQuery as a requirement

The idea is to offer the user the choice of either accessing the DOM using jQuery or native.

Changes to the API

In jQuery mode, all $something continue referring to jQuery sets, and selectors (e.g. inputs, excluded, ...) refer for jQuery selectors. In native they refer to a DOM element (or array of DOM elements) and HTML5 selectors respectively. While these are often compatible, jQuery supports more pseudo selectors as well as custom selectors.

Similarly, in jQuery mode, Ajax options refer to jQuery options, while in native mode, they refer to fetch options.

Implementation

  1. Go through all current uses of jQuery and convert to vanilla when reasonable:
  2. use native DOM (e.g. $.fn.attr => getAttribute). Must be 100% compatible, e.g. there is no equivalent to find(options.inputs) as jQuery selectors are more powerful than native ones.
  3. replace with ES6 calls (e.g. $.fn.each => loop). Must be IE8+ compatible (with es5shim)
  4. replace with CSS? (e.g. fadeIn => CSS animations, see #777)
  5. Create a DOMInterface class to be used to access the DOM & Ajax.
  6. Go through remaining uses of jQuery and move them to DOMInterface. This includes the way that promises are used to convert validator results and how they are combined
  7. Implement DOMInterface for native mode.
  8. Make the full test suite run twice, once with jQuery, once with native
  9. Update documentation
Clone this wiki locally