[css-values-3] serialization of fragment URLs in image properties · Issue #3195 · w3c/csswg-drafts (original) (raw)

https://drafts.csswg.org/css-values-3/#local-urls

Should properties that take <url>s as images serialize fragment URLs as just the fragment or as the full, resolved URL? The spec doesn't make any distinction between <url>s for images and non-images (such as various SVG properties like marker-start). The fragment URL concept was introduced to make it easier to use local references for non-image properties when the base value might change, and local URLs don't really make sense for images.

Test: https://mcc.id.au/2018/10/url-fragment-serialize.html

Results

background-image mask-image filter marker-start
specified computed specified computed specified computed specified computed
Chrome url("#x") url("https://mcc.id.au/2018/10/url-fragment-serialize.html#x") url("#x") url("#x") url("#x") url("#x")
Edge url("#x") url(https://mcc.id.au/2018/10/url-fragment-serialize.html#x) url(#x) none url("#x") url("#x")
Firefox url("#x") url("https://mcc.id.au/2018/10/url-fragment-serialize.html#x") url("#x") url("https://mcc.id.au/2018/10/url-fragment-serialize.html#x") url("#x") url("#x") url("#x") url("#x")
Safari url("https://mcc.id.au/2018/10/url-fragment-serialize.html#x") url("https://mcc.id.au/2018/10/url-fragment-serialize.html#x") url("#x") url("#x") url("#x") url("x")

All four browsers I tested serialize the computed value of background-image with a fragment as the entire resolved URL. (Safari is an odd one out in serializing the entire resolved URL for the specified value, too. And there's a bug in the marker-start computed value serialization.)

I think it makes sense to treat image and non-image <url> values the same way wrt fragment URLs, but since nobody implements this behavior I wanted to check to make sure it's what we all agree with before changing.