Skip to content

Conversation

@romainmenke
Copy link
Contributor

fixes : #287

let unbalanced = 1;
this.position ++;
if (last && last.type === types.PSEUDO) {
const selector = new Selector({source: {start: tokenStart(this.tokens[this.position - 1])}});
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell this was always incorrect.

this.tokens[this.position - 1] is the open parenthesis, but that isn't the start token of the selector. The selector starts inside the parenthesis.

:is(foo)
    ^ here

:is(foo)
   ^ not here

By comparison when the selector is part of a list and follows a comma it also does not have the comma as the start position. It starts after the comma.

:is(foo,bar)
        ^ here

:is(foo,bar)
       ^ not here

@alexander-akait alexander-akait merged commit 6485caf into postcss:master May 22, 2024
@romainmenke romainmenke deleted the add-source-index-to-selector-nodes--courteous-echidna-efbdb3ba14 branch May 22, 2024 14:16
@romainmenke
Copy link
Contributor Author

Thank you @alexander-akait 🙇

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.

sourceIndex on Selector nodes

2 participants