Removed space before square brackets in CSS style attribute #31270
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.
Deno’s HTML formatter was incorrectly inserting a space before square brackets in CSS property values inside style attributes. For example:
animation-[value] → animation- [value]
This resulted in invalid CSS syntax and caused issues when using bracket-notation utilities.
This PR adds a post-processing step to preserve valid -[ sequences after malva formats inline CSS. The new fix_css_bracket_spacing() function removes unintended spaces between hyphens and [ characters in CSS property values, ensuring that patterns such as animation-[value] remain correct and unchanged.
Summary of Changes
Added fix_css_bracket_spacing() to normalize bracket syntax after malva’s CSS formatting.
Integrated this fix into the HTML formatting pipeline for inline CSS inside style attributes.
Verified that the example from the issue formats correctly without inserting unwanted spaces.
Confirmed that no other CSS formatting behavior is affected.
Testing & Validation
Added/updated tests to cover this behavior.
cargo test --manifest-path cli/Cargo.toml tools::fmt::test passes.
./tools/format.js runs without producing any diffs.
./tools/lint.js passes.
Checklist
Descriptive PR title
References related issue (#30991)
Tests cover the change
cargo test passes
./tools/format.js passes
./tools/lint.js passes