Add CSS Images 4 image functions and fix value-context hash tokenization#209
Open
jhaygood86 wants to merge 1 commit into
Open
Add CSS Images 4 image functions and fix value-context hash tokenization#209jhaygood86 wants to merge 1 commit into
jhaygood86 wants to merge 1 commit into
Conversation
jhaygood86
marked this pull request as ready for review
July 22, 2026 23:02
image-set(), cross-fade() and element() (CSS Images 4 2/3) are valid
<image> values but were rejected. Add ImageSetConverter,
CrossFadeConverter and ElementImageConverter, composed into
ImageSourceConverter so every <image> property accepts them.
element(#id) needs a working <hash-token> in a value context, which
exposed a lexer bug: in a value context '#' was treated as a color
literal and consumed only hex characters, so "#hero" became an empty
color plus a stray "hero" ident. Per CSS Syntax 4.3.4 a '#' begins a
whole <hash-token> consuming an entire <name>; classify it as a color
only when the name is all hex, otherwise emit a Hash token. ValueBuilder
now accepts Hash tokens in a value.
Also add the "x" resolution unit, the canonical alias for "dppx" (CSS
Values 4 7.4), which image-set() options idiomatically use ("1x"/"2x").
jhaygood86
force-pushed
the
feature/css-images-4
branch
from
July 23, 2026 22:28
266f264 to
31547f2
Compare
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.
Feature
image-set(),cross-fade()andelement()(CSS Images 4 §2/§3) are valid<image>values but were rejected:Adds
ImageSetConverter,CrossFadeConverterandElementImageConverter, composed intoImageSourceConverterso every<image>property accepts them.Bundled lexer fix (required by
element(#id))element(#hero)needs a working<hash-token>in a value context, which surfaced a lexer bug. In a value context#was treated as a colour literal that consumed only hex characters, so#herotokenized as an emptyColorplus a strayheroIdent.CSS Syntax §4.3.4 says
#begins a whole<hash-token>consuming an entire<name>. The fix classifies it as a colour only when the name is all-hex (#f00,#abc123), otherwise emits aHashtoken (#hero,#f00bar); a#not followed by a name is a plain delimiter.ValueBuildernow acceptsHashtokens in a value.xresolution unitimage-set()options idiomatically use1x/2x.xis the canonical alias fordppx(CSS Values 4 §7.4); it was missing fromResolution.GetUnit.Tests
Tokenization.cs:#f00/#abc123/#deadbeef→Color;#hero/#top/#f00bar→Hash;#alone → delimiterPropertyTests/BackgroundProperty.cs: 5 legal (image-setstring & url with1x/2dppx, bothcross-fadeforms,element(#hero)) and 3 malformed (image-set(banana),element(.klass),cross-fade(5px))The full suite (1263 existing tests) stays green — the value-context hash change doesn't disturb any colour parsing — and all seven target frameworks build with no new warnings.