Skip to content

Wrap string URLs with decimal resolutions or type() in -webkit-image-set() - #1580

Merged
ai merged 1 commit into
postcss:mainfrom
itisrmk:fix/image-set-url-wrap
Dec 1, 2026
Merged

ai merged 1 commit into
postcss:mainfrom
itisrmk:fix/image-set-url-wrap

Conversation

@itisrmk

@itisrmk itisrmk commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

ImageSet#replace() previously matched only integer resolutions (\d+\w) when wrapping bare string URLs in url(...) for -webkit-image-set(). Decimal resolutions like 1.5x, .5x, or 1.25dppx, as well as string URLs followed by type(...), were left unwrapped, producing invalid -webkit-image-set() syntax in WebKit/Blink.

Input CSS

h2 {
  background-image: image-set('foo@0.5x.png' .5x, "foo@1.5x.png" 1.5x, "foo@1.25.png" 1.25dppx);
}

h3 {
  background-image: image-set("foo.avif" type("image/avif") 1x, 'foo.webp' 1.5x type('image/webp'));
}

Current output CSS

h2 {
  background-image: -webkit-image-set('foo@0.5x.png' .5x, "foo@1.5x.png" 1.5x, "foo@1.25.png" 1.25dppx);
  background-image: image-set('foo@0.5x.png' .5x, "foo@1.5x.png" 1.5x, "foo@1.25.png" 1.25dppx);
}

h3 {
  background-image: -webkit-image-set("foo.avif" type("image/avif") 1x, 'foo.webp' 1.5x type('image/webp'));
  background-image: image-set("foo.avif" type("image/avif") 1x, 'foo.webp' 1.5x type('image/webp'));
}

Output after the fix

h2 {
  background-image: -webkit-image-set(url('foo@0.5x.png') .5x, url("foo@1.5x.png") 1.5x, url("foo@1.25.png") 1.25dppx);
  background-image: image-set('foo@0.5x.png' .5x, "foo@1.5x.png" 1.5x, "foo@1.25.png" 1.25dppx);
}

h3 {
  background-image: -webkit-image-set(url("foo.avif") type("image/avif") 1x, url('foo.webp') 1.5x type('image/webp'));
  background-image: image-set("foo.avif" type("image/avif") 1x, 'foo.webp' 1.5x type('image/webp'));
}

Validation

  • pnpm test passes (289/289 tests, 100% line coverage, oxlint, and size-limit).

…set()

Co-Authored-By: Rahul Kashayp <30754662+itisrmk@users.noreply.github.com>
@ai
ai merged commit ddc117b into postcss:main Dec 1, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants