Skip to content

fix(css): handle nested functions in image-set() candidates (fix #23472) - #23521

Open
Comicao1 wants to merge 1 commit into
vitejs:mainfrom
Comicao1:fix/image-set-nested-parens
Open

Comicao1 wants to merge 1 commit into
vitejs:mainfrom
Comicao1:fix/image-set-nested-parens

Conversation

@Comicao1

@Comicao1 Comicao1 commented Sep 19, 2026 •

Copy link
Copy Markdown

Fixes #23472.

The image-set() rewriting broke on candidates with nested functions, e.g. linear-gradient(to right, rgba(0,0,0,0), rgba(0,0,0,1)). Two regexes were hitting the classic "can't match balanced parens" problem:

  • cssImageSetRE stopped the image-set(...) capture at the first inner ), so the candidate list got truncated and the trailing descriptor was left dangling
  • parseSrcset then also split such candidates at the inner commas

Replaced both with a small paren-aware scanner (quote and escape handling included). Behavior for -webkit-image-set(), commas inside unquoted urls, and unbalanced input is unchanged.

Added unit tests for rewriteCssImageSet (nested functions, webkit prefix, multiple occurrences, unbalanced input) and for parseSrcset with nested candidates. Full packages/vite unit suite passes (942 tests), lint + typecheck clean.

@Comicao1 Comicao1 changed the title fix(css): don't truncate image-set() candidates with nested parentheses (fix #23472) fix(css): handle nested functions in image-set() candidates (fix #23472) Sep 19, 2026

This branch has not been deployed

No deployments
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.

fix: image-set() URL rewrite truncates on nested parentheses

1 participant