4 ms·
If your browser requirements are IE9+, then there's little need for things like underscore (and, arguably, even jQuery) since you can count on x-browser support
by _jmar777 14y ago
If your browser requirements are IE9+, then there's little need for things like underscore (and, arguably, even jQuery) since you can count on x-browser support for things like document.querySelectorAll() and other niceties that jQuery typically levels the playing field for.
For example, why would there have been confusing over _.each vs. $.each when you have perfectly consistent native support for [].forEach? Nothing against Dart... it's cool and all, but I'm not sure the JavaScript "fragmentation" rationale is all that strong when you have the luxury of only dealing with such modern implementations.
- michaelwww 14y agoMy understanding is that people continue to use jQuery because it makes DOM manipulation that much easier. The Dart authors kept this in mind and said jokingly on http://www.dartlang.org/articles/improving-the-dom/ http://www.dartlang.org/articles/improving-the-dom/ One area where the DOM has a bunch of baggage is finding elements. Today’s DOM has a pile of methods for finding stuff. All of this piled up before jQuery appeared on a mountaintop to give us the revelation that Thou Shalt Find Nodes By Using CSS Selectors. With the One True Way in hand, we’ve stripped it down to just two (!) methods: query() and queryAll().
- _jmar777 14y agoI'm all for simplicity, and, again, this isn't an argument against Dart. But I would still contend that merely shrinking your DOM API surface area is only of marginal significance. Historically, the hardest part of interacting with the DOM has been the inconsistencies (and missing functionality) amongst ancient browser versions. We've had standardized methods for a long time now that make DOM interactions relatively trivial if you have the luxury of working with browsers that support them.
- munificent 14y ago> Historically, the hardest part of interacting with the DOM has been the inconsistencies (and missing functionality) amongst ancient browser versions. Even newer browsers have a surprising amount of DOM inconsistencies, especially for newer HTML5 APIs that are still evolving. While this is an ongoing job, the Dart DOM API tries hard to polyfill that so that you get a single API that works across most browsers.
- lobster_johnson 14y agoQuerying is only a small part of it, though. jQuery provides result sets as proxies for the actual objects. So this: $(".foo").css("color", "green"); will actually apply the CSS to all matches. This becomes doubly handy when doing things like attaching event handlers, removing nodes, etc. Looking at Dart's API, I don't see anything like it; queryAll() returns a List<Element>. In order to act on a collection of elements, you have to use iteration mechanisms such as for loops. The whole concept behind jQuery's $() is that it's a DSL.