Skip to content

Fix case-insensitive value detection - #1563

Merged
ai merged 3 commits into
postcss:mainfrom
wozhenbang2004:fix-case-insensitive-values
Nov 6, 2026
Merged

ai merged 3 commits into
postcss:mainfrom
wozhenbang2004:fix-case-insensitive-values

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Uppercase and mixed-case image-set() names are skipped before the existing case-insensitive replacement runs. For example, Safari 9 gets no prefixed declaration for background-image: IMAGE-SET(url(Logo.PNG) 1x).

Cache a non-global case-insensitive name detector, initialized on the first check so subclasses can normalize their names during construction. Keep the existing value boundaries and original spelling. Tests cover the public image-set path, repeated checks, and quoted-name controls.

Validation: 273 unit tests passed with 100% line coverage; lint, declaration checks, and size checks passed.

A small end-to-end comparison used identical lowercase outputs, 30 compilations per sample and three alternating-order rounds. Median time was 163.45 → 154.74 ms for repeated repository fixtures and 49.38 → 50.53 ms for 77 KB of long negative values. The cached check itself remains slower than the original case-sensitive includes on long negative strings.

For 200,000 detector calls (median of five rounds):

Input Original includes Cached /i Lowercase copy
Ordinary lowercase 8.04 ms 7.51 ms 8.80 ms
Long negative value 12.74 ms 38.36 ms 39.91 ms
Lowercase match 19.84 ms 21.36 ms 23.02 ms

The existing replacement expression can also match function-like text inside a quoted URL after a space. Newly recognized uppercase text inherits that edge case: a prefixed clone may be produced, while the original URL declaration remains last. The detector change keeps that replacement logic intact.

@ai
ai merged commit 58135fa into postcss:main Nov 6, 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