Re: [dom] matches, querySelector, etc. shouldn't throw on an unrecognized selector (#39)

If I look at the currently-most-recent jQuery 2 version (code at <http://code.jquery.com/jquery-2.1.4.js>) then on line 841 there is a `querySelectorAll` call.  If that succeeds, the result is returned.  If it throws, the code falls through to the custom `select` call at line 855. 

Similarly the most recent jQuery 1 version at http://code.jquery.com/jquery-1.11.3.js has the same sort of setup, on lines 879 and 893 respectively.

Looking at the file you linked to for jQuery, https://github.com/jquery/sizzle/blob/a7020477b0433ac08d66baf9eebb3f9d24868e21/src/sizzle.js#L308 has the corresponding call.  If that succeeds, then `results` is returned, which will always be truthy (it's an empty array, worst-case, which is still truthy) so the code you quoted will go ahead and return the empty array.

As for mootools, the matching function you point to would probably still work, yes (it's using `matchesSelector`, which doesn't even exist, not querySelector), but the code at https://github.com/mootools/slick/blob/f9503a24e69e442fa926e34ff85d1cdb874b97bd/Source/Slick.Finder.js#L381-387 wouldn't.



---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/39#issuecomment-108007717

Received on Tuesday, 2 June 2015 16:33:56 UTC