New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle interpolation in selector-nest-combinators #307
Handle interpolation in selector-nest-combinators #307
Conversation
} | ||
|
||
// attribute, class, combinator, comment, id, nesting, pseudo, root, selector, string, tag, or universal | ||
const chainingTypes = [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I move these things on top, so that they're not inside a loop
@lxsymington maybe you want to have a look at the changes for my bugfix? :) |
let message; | ||
|
||
fullSelector.walk(node => { | ||
if (node.value === "}") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added this because the selector parser can not properly parse interpolation, so the }
was being reported on its own.
"universal" | ||
]; | ||
|
||
const interpolationRe = /#{.+}$/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is checking for the presence of any interpolation in the current selector, it's probably not particularly relevant, but would it generallly be better to use the non-greedy + operator? So that it would not match the whole of #{$var} .selector li #{$var-2}
. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#quantifiers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, it's better to make it non-greedy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Just a non-blocking query about the regex
Fixes #306