New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

querySelectorAll workaround is not always needed #430

wartmanm opened this Issue Oct 22, 2018 · 0 comments


None yet
2 participants

wartmanm commented Oct 22, 2018

If I understand it correctly, the issue with qSA that 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment