AdguardTeam / ExtendedCss

A TypeScript library for non-standard element selecting — :contains(), :matches-css(), etc., and applying CSS styles with extended properties.
GNU General Public License v3.0
61 stars 9 forks source link

Performance of ':xpath()' pseudo-class selectors #115

Closed ameshkov closed 3 years ago

ameshkov commented 3 years ago

Try adding this selector and check what happens: youtube.com#$#:xpath(//div[@class='ytp-button ytp-paid-content-overlay-text']) { display: none; debug: true; }

We should handle naked :xpath selectors differently and pass it to document.evaluate right away: :xpath(//div[@class='ytp-button ytp-paid-content-overlay-text'])

The problem itself is caused by the way right-to-left matching works in Sizzle - for a selector like that it basically takes ALL DOM nodes and evaluates the pseudo-class for it.