Repository navigation
Do not split list.comma() and list.space() on separators inside comments - #2162
Merged
Merged
Conversation
Quotes, functions, and escapes were already skipped; commas and spaces inside /* … */ still broke Rule#selectors and the public list helpers.
Member
|
Thanks! Do you need it right now? Or it is OK to wait another feature for release? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2161.
list.split()already ignores separators inside quotes and functions, and it already treats\\,/\\as escaped. It still walks into/* … */comments, so a comma or space in a comment is treated as a real separator — including parentheses, which throws off the function-depth counter:Rule#selectorsislist.comma(this.selector), so the same input splits a selector list:The parser strips comments from selectors and declaration values, so a
parse()round-trip hides this. The helpers are documented as a safe split, and they are what plugins (andRule#selectors) use on strings that may still contain comments.The change
While scanning, treat
/*…*/as a comment (same nesting rules as CSS: no nested comments, unclosed comments run to the end). Separators, quotes, and parentheses inside a comment are not significant./*inside quotes or after\\is unchanged.comma()/space()emptiness behaviour from #2134 / #2141 is untouched.Tests
New cases in
test/list.test.ts(comma inside a comment, comment-only value, unclosed comment, quoted/*, escaped slash, spaces and parentheses inside comments) and one intest/rule.test.tsforRule#selectors. All fail onmainand pass here.list.jsstays at 100% line/branch coverage.