feat: minify colors in var() fallback values - #1143
Open
yisibl wants to merge 7 commits into
Open
Conversation
For security purposes, a whitelist mechanism has been added, which only takes effect for color-related properties and within `var()` expressions.
Add support for minifying colors inside var() fallback values when usedwithin CSS gradient functions and image-related properties. Changes: - Rename `COLOR_KEYWORDS` to `MINIFY_COLORS_IN_FN` - Extend has_color_function() to include more gradient functions and `image-set()`: - Update tests to verify color minification in var() fallbacks
yisibl
marked this pull request as draft
February 2, 2026 02:39
Preserve parsing context when reading var() fallbacks inside unparsed property token lists, so color-ident minification respects function-level whitelisting instead of being reapplied as top-level parsing. e.g. Added/updated regression tests in test_custom_properties covering: non-whitelisted function: foo(var(--c, blue)) should keep blue,
yisibl
force-pushed
the
minify-color-in-var
branch
from
February 8, 2026 16:10
1077b8e to
c8c21ea
Compare
…colors Pass function-level `TokenListParseOptions` into `UnresolvedColor::parse` so `light-dark(...)` arguments inherit the same color-ident minification context as the surrounding function parse. In the unresolved `light-dark` branch, parse light/dark arguments with `TokenList::read_token_list(..., parse_options)` instead of `TokenList::parse(...)`, so `var()` fallbacks can be minified where allowed while still respecting non-whitelisted nested functions.
yisibl
marked this pull request as ready for review
February 8, 2026 17:10
Contributor
Author
|
@devongovett This is ready for review, PTAL |
yisibl
force-pushed
the
minify-color-in-var
branch
from
February 11, 2026 09:25
fbffc31 to
a83cc2c
Compare
Contributor
Author
|
@devongovett ping~ |
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.
Fixes: #601