andybalholm / cascadia

CSS selector library in Go
BSD 2-Clause "Simplified" License
703 stars 65 forks source link

Fix :nth-child selectors pseudo-classes for the root element #52

Closed WGH- closed 3 years ago

WGH- commented 3 years ago

:nth-child and related selectors should work on the root element. They do in browsers, and according to CSS selector spec, "It is not required to have a parent."[1].

[1] https://drafts.csswg.org/selectors-3/#nth-child-pseudo

andybalholm commented 3 years ago

That makes sense to me. But we should check with @ryancox since he's the one that put in those checks that you're taking out, and see what he has to say.

ryancox commented 3 years ago

sgtm ... thanks for adding tests along with the change