Repository navigation
Do not duplicate words between property and colon - #49
Merged
Merged
Conversation
Parser#decl() keeps the words between the property and the colon in raws.between and calls unknownWord() for them. The safe parser's unknownWord() added them to the spaces before the next node too, so the output had them twice.
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.
A word between a property and its colon gets into the output twice:
Parser#decl()keeps such words inraws.betweenand callsunknownWord()for them. The safe parser'sunknownWord()adds them tothis.spacestoo, so they also get into theraws.beforeof the next node or theraws.afterof the parent.It happens while typing a new property above an existing one. Stylelint parses CSS with this parser when fixing (
--fixin 16.x,--fix=laxin 17.x) and writes the output back. Afterstylelint --fix(16.26.1) on the CSS above, Chrome 154 stops applyingmargin-left, because the copiedcolorandmargin-left: 10pxread as one invalid declaration.Now
decl()clearsthis.spacesaftersuper.decl().init()empties it when the declaration starts, so only this copy is there. I added atoString()check to thefixes 2 properties in safe modetest. It fails onmainwitha { color one: white;one one }.pnpm testpasses.