In modern browsers, jQuery uses document.querySelectorAll() to improve performance when using the correct CSS selectors. It returns to Sizzle if the browser does not support the selector or the document.querySelectorAll() method.
However, I would like to use Sizzle instead of my own implementation when debugging a custom selector. Namely, I'm trying to come up with an implementation :nth-last-child() , one of the CSS3 selectors that are not supported by jQuery . Since this selector is supported on modern browsers, it works as described in a related question. It is this behavior that prevents the debugging of my custom selector, so I would like to avoid it.
A cheap hack that I can use is to abandon the non-standard extension of the jQuery selector , thereby βinvalidβ the selector, so to speak, For example, if we assume that every li:nth-last-child(2) visible , I can just delete it by turning this:
$('li:nth-last-child(2)').css('color', 'red');
In it:
$('li:nth-last-child(2):visible').css('color', 'red');
This makes him always value Sizzle. In addition, this requires me to make assumptions about page elements that may or may not be true. And I really don't like it. Not to mention the fact that I do not like the use of non-standard selectors in general, if this is absolutely necessary.
Is there a way to skip the native document.querySelectorAll() method in browsers that support it and force jQuery to use Sizzle to evaluate the selector instead, which preferably does not use the use of non-standard selectors? This is probably due to calling another method instead of $() , but it is much better than a selector to crack IMO.
Boltclock
source share