Repository navigation
🐛 fix(css): close only matching blocks in minify_css - #1634
Merged
Merged
Conversation
gaborbernat
enabled auto-merge (squash)
November 5, 2026 14:49
for more information, see https://pre-commit.ci
Merging this PR will not alter performance
Comparing Footnotes
|
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_csskept growing its own output when a stylesheet ended inside a function whose arguments held an open[or{block with a)inside, such asr{r:l([[)}, or inside an invalidunicode-rangevalue (#1633). Every pass appended another}, so pipelines that minify already-minified CSS, and cache keys built from the result, never settled. Such input now minifies to the same text on every pass. 🔁The minifier read nesting three ways: the declaration reader let any closer end the innermost block, function matching looked only at parentheses, and the end-of-input repair matched closers to their own kind. Each of them now reads blocks as CSS Syntax 3 §5.4.7 does, the same reading turbohtml's CSSOM and tinycss2 use: a block ends only at its own closer, and any other closer inside it is a plain value. The closers written at the end of the input therefore match what the next pass reads. The invalid
unicode-rangefallback, which copied the value verbatim, now gets those closers as well.Behavior changes
r{r:l([[)}now minifies tor{r:l([[)}]])}rather thanr{r:l([[)}}, and@x ({))keeps its))inside the{and gains}).@mediarule whose only content is a block that swallows the rest of the input now minifies to nothing, as an empty@mediadoes elsewhere.Closes #1633