Starting To Oust Sizzle From jQuery |
Written by Ian Elliot | |||
Tuesday, 16 April 2019 | |||
jQuery 3.4.0 has just been released. It is the last minor release on the 3.x branch and in preparation for the removal of the Sizzle selector engine from the next major release, jQuery 4.0, it deprecates Sizzle's, non-standard, positional selectors. We didn't cover jQuery 3.3.0, quickly superseded by 3.3.1, when it was released over a year ago on the ground that it was a minor release that was mainly deprecations of functions that had outlived their usefulness. it included only one new feature - that the As Timmy Willison, team lead for jQuery Core, reminds us in his blog post announcing jQuery 3.4: The basic API of jQuery is to select something and then do something with what was selected. Sizzle, the selector engine in jQuery, handles the first half. It’s been a fast and efficient little engine that has paved the way for native selector APIs like querySelectorAll and additional native JavaScript and CSS selectors. While initially part of jQuery, Sizzle has had a wider-ranging influence and its selectors have made their way into modern browsers, making them redundant in jQuery, hence the decision to remove Sizzle in jQuery 4.0. To pave the way for this change, in which Sizzle will be replaced by a small wrapper around querySelectorAll, the following list of non-standard positional selectors, that would be almost impossible to reimplement without a larger selector engine, are being deprecated: :first Noting that the postional methods, such as: .first will still be supported, Willison says, and I have to agree with him: Anything you can do with positional selectors, you can do with positional methods instead. They perform better anyway. On the other hand if you have to support a legacy browser, such as IE, Internet Explorer, you may need to continue to use Sizzle, either by using an version of jQuery pre-dating 4.0, the date for which has yet to be announced, or by downloading Sizzle itself. One of the other changes in jQuery 3.4.0 addresses an event handling issue, expected state, that had been fixed with checkboxes but accidentally left out radio inputs. Now when an element is clicked and true is logged the checked property is updated before the event handler is executed as in this example:
Another fix is for the Prototype Pollution vulnerability which caused unintended behaviour when using:
Until now if an unsanitized source object contained an enumerable
As well as including the fix in this release patch diffs have been made available by Daniel Ruf on GitHub for previous versions. Willison warns however: Note that while jQuery does its best to protect users from security vulnerabilities, jQuery is a DOM manipulation library that will generally do what you tell it to do. In this case, the behavior was likely unexpected, so Also in the new release, there's a performance improvement in .width and .height to eliminate layout thrashing when getting and setting dimensions. This is fixed in all browsers apart from IE. Finally, with regard to adding script elements through methods like .html and .append, support has been added for the previously ignored nonce and nomodule attributes. jQuery 3.4 now hangs on to them to load and execute the remote content they refer to. All in all this seems a worthwhile minor upgrade, leaving this branch in a good state and allowing the community to move on to jQuery 4. As well as the standard version of jQuery 3.4.0, which can be obtained from the jQuery CDN or directly: https://code.jquery.com/jquery-3.4.0.js https://code.jquery.com/jquery-3.4.0.min.js there is a "slim" version that excludes the ajax and effects modules, saving about 6k zipped bytes: https://code.jquery.com/jquery-3.4.0.slim.js https://code.jquery.com/jquery-3.4.0.slim.min.js While there are many of the opinion that you don't need jQuery any more - this is simply a reflection of how little the person advocating the point of view knows about jQuery. It isn't just about the selectors. It is still the standard library of JavaScript and a lesson in writing good JavaScript to all of us.
More InformationGitHub Changelog for jQuery 3.4 Related ArticlesjQuery Still Our Favourite Framework Vanilla JS Used On More Sites Than jQuery jQuery 3.2.1 Is Out - Do We Still Care? jQuery Adopts Semantic Versioning OpenJS Foundation - New Merged Foundation For JavaScript To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info <ASIN:1871962501> <ASIN:1871962528> <ASIN:1871962579> <ASIN:1871962560> < |
|||
Last Updated ( Tuesday, 16 April 2019 ) |