Repository navigation
Conversation
`parser.id({ value: "hover:bg" })` printed as `#hover:bg`, which parses back
as an id followed by a `:bg` pseudo. Assigning the same value after
construction escaped the colon. postcss#349 fixed this for class names; ids had
the same gap.
The constructor now goes through the escaping setter unless `raws.value`
is given, and the parser drops the raws it adds, as it does for classes,
so parsed ids keep their original spelling.
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.
#349 made
parser.className({ value })escape its value, which fixed #182.parser.id({ value })has the same gap:#hover:bgparses back as the idhoverfollowed by a:bgpseudo-class, so a selector built through the API comes out with a different meaning.The fix
The same change #349 made for
ClassName. TheIDconstructor runs its value through the escaping setter unlessraws.valuewas given. InsplitWord(), the parser removes the raws the constructor adds when it had none, as it does for class names, so parsed ids keep their original spelling, including Less such as#foo@{bar}.Verification
The tests mirror the ones #349 added for classes: five values that need escaping (a colon, a leading digit, a dot, a backslash, a non-ASCII character), explicit
raws.value, a plain identifier getting no raws, and parsed ids keeping their raws state when cloned. The five escaping tests fail onmain.npm testis green: lint, type check, and coverage gates.