Repository navigation
🐛 fix(css): keep stray brackets stable on repeat - #2194
Merged
Merged
Conversation
A stray bracket, or an ident written apart from a `(`, came out of the first minify pass in a form that the second pass changed. A declaration whose name opened a block before its colon was kept on the first pass and dropped on the second. An ident followed by `(` joined into a function token, which the second pass closed. A nested calc() left open at the end of the input stayed unfolded until the second pass. A name that opens a block is no declaration, so the first pass drops it. An ident written apart from a `(` gets a space in stray text, and a block left open after a hex escape gets the space the second pass writes. A nested calc() or group that reaches the end of the input is folded on the first pass. Fixes tox-dev#1853
Merging this PR will not alter performance
Comparing Footnotes
|
A raw at-keyword name that ends in a hex escape took no closing space, so the first pass wrote one space before the prelude and the second pass, reading the escape's space back as part of the name, wrote two. A stray `}` or `;` after stray text that was written after the last delimiter cleared the delimiter owed before the next at-statement, so the first pass joined the two and the second pass split them again. Write the closing space for a raw name that ends in a hex escape, as a spelled name does, and keep the delimiter before an at-statement that follows stray text. Fixes tox-dev#1853
# Conflicts: # src/turbohtml/_c/css/minify/css_calc.h
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.
minify_cssandminify_css_inlinecould give a different result when run a second time on some input with stray brackets, hex escapes or CDO/CDC tokens. Running the minifier on its own output could therefore change the stylesheet, which breaks pipelines that minify more than once. 🧱 Once this merges, a second pass returns the first pass's output unchanged. Fixes #1853.Each mismatch came from the first pass writing text that a second pass reads differently. The first pass now writes what the second pass would read: a declaration whose name opened a block is dropped, an ident stays apart from a following
(, a group left open at the end of the input is closed, and an escaped name keeps the closing space the second pass expects. The rules follow CSS Syntax 3, which defines how such input is parsed.Behavior changes
styleattribute.(in stylesheet text is separated from it by a space.calc()or group left open at the end of the input folds to its value.;before the at-statement.