Description
If I understand it correctly, the issue with qSA that https://github.com/jquery/sizzle/blob/master/src/sizzle.js#L301 works around is that it matches using the entire document, including the context element's parents. But this should only be relevant if there are child or descendant combinators in the selector. Without them, it shouldn't be possible for the search to ascend above the context element, and so qSA will return the desired results without any special effort.
By skipping the workaround, the potentially expensive setAttribute
and removeAttribute
calls can be avoided. I would hope that browsers' native qSA machinery would benefit from simpler selectors as well.
I think the types of simple selectors, like div.class.anotherClass
, that can benefit from this are relatively common, and checking if a selector qualifies is cheap since it already has to be tokenized.