fix(issue:4211) parse entities in comma list#4214
fix(issue:4211) parse entities in comma list#4214puckowski wants to merge 1 commit intoless:masterfrom
Conversation
correctly parse all entities in a comma separated list such that all URLs are rewritten correctly
|
@puckowski When I did the original custom property implementation to unblock people using custom properties, it was a somewhat naive implementation. Here is the original problem:
My naive implementation worked like this:
I would now classify this as a bad solution, and:
Why the current implementation is badEven though a custom property can superficially look like a CSS property, it isn't, and its parsing rules are not similar. CSS has no unified syntax; it is a collection of "micro-syntaxes" and the syntax rules are flipped on/off depending on what preceded it. Take this example: .box {
@width: 30px;
--my-width: @width;
}What should happen? Currently, we can superficially imagine that the author wants to treat this like a regular property and sub in the variable value. We get this output: .box {
--my-width: 30px;
}However, this too is a valid custom property: .box {
--my-custom-syntax: #define @query => (val + 30);
}It's unclear when an author is writing a custom property value if they intend to use JavaScript or a CSS worklet to interpret the values differently, and, in general, those values should be preserved. (Incidentally, this is technically true of unknown at-rules, which have their own micro-syntaxes.) But, today, Less will throw an error that Instead, my feeling is that the custom property value node should be, entirely, an anonymous value with interpolated variable substitutions only. Meaning the author would be required to write: .box {
@width: 30px;
--my-width: @{width};
}
Related to this issueSo, as to the URL issue itself as it relates to lists, my feeling is that the fact that Less is re-writing URLs at all in a custom property is an unintended side-effect behavior, and the "fix" is not to rewrite more URLs, but to rewrite no URLs, because we do not know author intent. However, this would be a breaking change and should come with: |
correctly parse all entities in a comma separated list such that all URLs are rewritten correctly
Resolves: #4211
Given:
where
index.lessimportsstyles.lessandstyles.lesshas the following:and
index.htmlincludesindex.lessand is served usingws, the output is:I ran all tests locally and they pass.
What:
Not all entities are parsed correctly in a comma separated list and may result in incorrect CSS output.
Why:
Users expect correct CSS output when using comma separated lists with valid CSS syntax.
Checklist: