Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: JQuery Removal #2414

Merged
merged 58 commits into from
Dec 8, 2023
Merged

Conversation

kumilingus
Copy link
Contributor

@kumilingus kumilingus commented Dec 5, 2023

Description

This PR removes dependency on jQuery.

We decided to use the jQuery library as a starting point for creating our own DOM utility. We have reduced the code to less than 30 kB (unminified).
We use it only for its implementation of event namespaces and event delegation (these are remain compatible with previous versions).
We use a WeakMap to store DOM elements data instead of adding hidden props to them.

This new tool is for internal use only.

Note: jQuery remains a devDependency as it is used in the generated documentation and a few demos.

Note: a reason why we didn't use the Cash library (jQuery alternative) was this issue.

Breaking Changes

  • drop support for JQuery selectors (now only CSS3 selectors are recognized)
    • Attribute not equal selector (!=)
    • Positional selectors (:first; :eq(n); :odd; etc.)
    • Type selectors (:input; :checkbox; :button; etc.)
    • State-based selectors (:animated; :visible; :hidden; etc.)
    • :has(selector) in browsers without native support
    • :not(complex selector) in IE
    • custom selectors via jQuery extensions
    • Reliable functionality on XML fragments
    • Matching against non-elements
    • Reliable sorting of disconnected nodes
    • querySelectorAll bug fixes (e.g., unreliable :focus on WebKit)
    • Selectors can not start with combinators (e.g "> div" needs to be converted to ":scope > div")
  • view.$el and view.$() are no longer public properties (use view.el and view.el.querySelectorAll() instead)
  • remove the following paper's protected properties: paper.$document, paper.$grid and paper.$background
  • utils.sortElement returns a plain array of Elements (not $ object)
  • it's no longer possible to access CellView from a DOM element ($.data(document.querySelector('.joint-cell').view)
  • cellView.prototype.findBySelector() removed in favor of findNode(), findPortNode() and findLabelNode() (resp. findNodes(), findPortNodes() and findLabelNodes() to find nodes referenced by a group selector).

Keep eye on

  • jQuery automatically adds units for CSS style values. Is there an API that used $.css() originally and does not expect the values to have units? e.g. { width: 100 } (Note that SVG attributes don't require units, so this only applies to CSS styles.)

kumilingus and others added 3 commits December 8, 2023 13:51
…pe/findPortNode.html

Co-authored-by: Zbynek Stara <zbynek.stara.internet@hotmail.com>
…pe/findPortNodes.html

Co-authored-by: Zbynek Stara <zbynek.stara.internet@hotmail.com>
…findLabelNodes.html

Co-authored-by: Zbynek Stara <zbynek.stara.internet@hotmail.com>
@zbynekstara zbynekstara merged commit 15a73d1 into clientIO:dev Dec 8, 2023
1 check passed
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.

None yet

4 participants