3 ms·
wrap elements in a node list This is not correct. You may say that it wraps or outputs elements in a node list like object but it is not the real deal. If you
by notNow 11y ago
wrap elements in a node list
This is not correct. You may say that it wraps or outputs elements in a node list like object but it is not the real deal. If you examine the emitted jQuery objects using instanceof or any other method, you'd see that they are not related to NodeList in any way. They're just generic objects of Object type.
- pluma 11y agoTrue, jQuery doesn't use the native NodeList for various reasons, but since QSA returns a NodeList, that'd be the equivalent for this "substitute".
- masklinn 11y ago> jQuery doesn't use the native NodeList for various reasons Those reasons being: * because it's garbage * because native objects shouldn't (and may not necessarily be) extended * because static nodelists didn't even exist back when jquery was created * because you can't create a nodelist in userland code
- pluma 11y agoAlso (and probably most importantly): * because NodeList instances are host objects and host objects often behaved in unexpected ways in older browsers and IE If you want to have a look at host object weirdness, try using `console.log` as if it were a function when using the F12 developer tools in IE8. Surprise: it can be invoked like a function, but it doesn't have any of the methods you'd expect a function to have (e.g. apply, call, let alone bind). Another host object quirk was that they were often read-only (which is why "thin" AJAX libraries can't manipulate the native XHR objects directly if they want to support IE8). "Who cares about IE8?" you ask? Surprisingly some sectors of certain industries still do (civil service in Germany, for example). If your market overlaps with those groups, you'll be thankful most of us were at least able to skip IE7 after IE6 finally died (I'm not sure whether we'll be as lucky with IE9 when IE8 finally bites the dust).