brave / adblock-rust

Brave's Rust-based adblock engine
Mozilla Public License 2.0
1.42k stars 123 forks source link

Support for CSS Selectors 4 Pseudo-Class :nth-child(an + b of S) #278

Open ghost opened 1 year ago

ghost commented 1 year ago

Shipped in Chromium 111 https://chromestatus.com/feature/5144225077788672 it extends :nth-child() and :nth-last-child() pseudo classes to take a selector.

Examples: :nth-child(-n+3 of li.important) tr:nth-child(even of :not([hidden]))

antonok-edm commented 1 year ago

~@Emi-TheDhamphirInLoveUnderTheFrozenStar thanks for reporting! This is actually handled just fine by adblock-rust. Instead it looks like there's just some issue in Brave where the selectors aren't working at all (even in a normal stylesheet). I suspect it's been enabled in Chrome 111 via an origin trial. I'll move this issue to brave-browser and see if we can investigate further there.~

Nope, I misunderstood how it's supposed to work and on closer inspection, it is definitely not supported in adblock-rust with the css-validation feature enabled. Looks like the selectors library would have to be updated to support it.