Skip to content

Implement nth-of-type when we are including the tagName#71

Open
eoghanmurray wants to merge 1 commit intoantonmedv:masterfrom
eoghanmurray:nthOfType
Open

Implement nth-of-type when we are including the tagName#71
eoghanmurray wants to merge 1 commit intoantonmedv:masterfrom
eoghanmurray:nthOfType

Conversation

@eoghanmurray
Copy link
Copy Markdown

An implementation of nth-of-type #3

The idea here is to never allow the combination of a tagName + :nth-child — from the point of view that it's

  • much more intuitive for humans reading it
  • might be more robust
    (reasons given by @kfrederix)

@eoghanmurray
Copy link
Copy Markdown
Author

eoghanmurray commented May 4, 2023

Highlighting one unexpected change to the test results ... the following is preferred as the algo immediately cuts off if a unique match is found at a given level:

        ++.-of2·p:nth-child(2)·>·a                   (Expected)
        --.cell:nth-child(1)·>·p:nth-of-type(1)·>·a    (Actual)

Before, .cell:nth-child(1)·>·p:nth-child(2)·>·a is checked, but found to be non-unique, so algo continues exploring higher levels.

I don't know if it's desirable to fix this or not? And don't know how best to fix.

Note: up for debate, but the 'desired' selector would be .-of2 p:nth-of-type(1) > a which is unique

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant