Keep underscores in dashed-idents #13538
Closed
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.
While working on the removal of automatic var injection (#13537), I noticed that underscores in variables are converted to spaces.
Before the automatic var injection removal, the following code would work:
However, the generated CSS looked like this:
One way to solve this is by escaping the underscore, but then you would have to use the variable like this:
If you are in a JavaScript context, this could even look like this:
Which looks a bit weird.
So this PR improves the code for handling the
by ensuring that dashed-idents width underscores are not converted to spaces.
_
conversion toOne caveat: there are properties, such as
anchor-name
, that accept multiple dashed-idents but luckily for us they are separated by commas instead of spaces. E.g.:If they were separated by a space, then
[anchor-name:--foo_--bar]
would be a problem because it could both mean:--foo --bar
--foo_--bar
... because
_
values are valid in dashed idents.If this ever becomes a problem, then we could special case
_--
to equal--
(notice the space). But that in turn would convert legitimate values that look like--foo_--bar
. Not sure if this is a real problem, because properties such asanchor-name
are comma-separated right now.