Skip to content

Stop appending "px" to unitless SVG paint and aspect-ratio values - #5233

Open
dylanpulver wants to merge 1 commit into
preactjs:mainfrom
dylanpulver:fix-unitless-svg-aspect-ratio
Open

Stop appending "px" to unitless SVG paint and aspect-ratio values#5233
dylanpulver wants to merge 1 commit into
preactjs:mainfrom
dylanpulver:fix-unitless-svg-aspect-ratio

Conversation

@dylanpulver

@dylanpulver dylanpulver commented Sep 3, 2026

Copy link
Copy Markdown

IS_NON_DIMENSIONAL misses five properties that reject a <length>, so the appended px makes the value invalid and the browser drops the declaration outright:

style={{ … }} today after
aspectRatio: 2 (nothing) aspect-ratio: 2 / 1
fillOpacity: 0.5 (nothing) fill-opacity: 0.5
stopOpacity: 0.5 (nothing) stop-opacity: 0.5
strokeOpacity: 0.5 (nothing) stroke-opacity: 0.5
strokeMiterlimit: 3 (nothing) stroke-miterlimit: 3

All five sit in React's isUnitlessNumber.

Corpus: every CSS property Chromium exposes, camelCase and kebab — 1,261 names. 26 classifications change, zero regressions: 10 dropped declarations restored, 6 are stroke-width/-dasharray/-dashoffset going 2px2 (spec-equivalent, matches React), 10 no-ops (fill, stroke, -linecap, -linejoin, stop-color reject a bare number either way).

Deliberately uncovered: boxFlex, boxFlexGroup, boxOrdinalGroup, flexPositive, flexNegative — React keeps them for the 2009 flexbox draft; Chromium accepts neither 2 nor 2px for any.

Two naive alternatives measured and rejected: f[lo]f[ilo] sweeps in filter and field-sizing and still leaves 4 of 5 broken; asp alone leaves 4 broken and fails the new test.

Reverting only util.js fails the new test and nothing else (46/47). Full suite 1306 passing; Compressed size 3,913 → 3,920 gzipped (+7 B).

🤖 Written with Claude Code (claude-opus-5)

IS_NON_DIMENSIONAL misses aspectRatio, fillOpacity, stopOpacity,
strokeOpacity and strokeMiterlimit. None accepts a <length>, so the
appended px makes the value invalid and the browser drops the whole
declaration: style={{ aspectRatio: 2 }} renders nothing at all.

All five are in React's isUnitlessNumber.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

📊 Tachometer Benchmark Results

Summary

A summary of the benchmark results will show here once they finish.

Results

The full results of your benchmarks will show here once they finish.

tachometer-reporter-action v2 for CI

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.

1 participant