gngr icon indicating copy to clipboard operation
gngr copied to clipboard

querySelectorAll should include an element only once

Open hrj opened this issue 10 years ago • 0 comments

Element should be included in the result only once.

Solution 1

Rewrite the current implementation. The DOM should be walked only once and every element should be checked against the full list of selectors using the jStyleParser's analyser.

Solution 2

Use a set instead of a list of elements. But this by itself won't guarantee that the results are in document order. Need to check if document order is required.

Future optimisation

The analyser does a reverse pass during its check. A future optimisation would be to change querySelectorAll's implemenation to match the elements with a single forward pass.

TODO: Create a new issue for this optimisation, once the functionality is done.

hrj avatar Jul 17 '15 15:07 hrj