Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

add sourceIndex to Selector nodes #290

Conversation

romainmenke
Copy link
Contributor

fixes : #287

@@ -685,7 +693,10 @@ export default class Parser {
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
4 checks passed
@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 🙇

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sourceIndex on Selector nodes
2 participants