Repository navigation
css: keep translate, rotate and scale apart from transform - #45210
Conversation
Port of parcel-bundler/lightningcss#1340. The handler appended an individual transform property declared after `transform` to the function list of `transform`, and dropped the ones declared before it. Both change the result: the individual properties cascade on their own and compose in a fixed order. transform: scale(3); scale: 0.5 was transform:scale(3)scale(.5) scale: 0.5; transform: scale(3) was transform:scale(3) transform: none; translate: none was transform:translate(0,0) Each property now keeps its own slot. The three `to_transform` helpers lose their only caller and are removed. Co-authored-by: Cong-Cong Pan <dacongsama@live.com>
|
Updated 9:57 PM PT - Oct 13th, 2026
✅ @robobun, your commit b257a67ffdd79ecd6d756cc9a4bb22bda8c2fd46 passed in 🧪 To try this PR locally: bunx bun-pr 45210That installs a local version of the PR into your bun-45210 --bun |
|
Status Reproduced with a release build of main at 772f87f. printf '.a{translate:10px;transform:rotate(10deg)}\n.b{transform:rotate(10deg);translate:10px}\n' > a.css
bun build a.css --minify
PR: #45210 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughTransformHandler now stores translate, rotate, and scale separately from transform declarations and flushes them separately. CSS tests cover declaration ordering, resets, identity values, importance, custom properties, and vendor prefixes. A helper registers TODO comparisons. ChangesCSS Transform Properties
Suggested reviewers: Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
Problem
translate,rotateandscaledeclared beforetransform, and appends those declared after it to thetransformlist..a{translate:10px;transform:rotate(10deg)}prints.a{transform:rotate(10deg)}..a{transform:rotate(10deg);translate:10px}prints.a{transform:rotate(10deg)translate(10px)}.TransformHandler::handle_property. Thetransformarm clears the three slots (src/css/properties/transform.rs:1021), andindividual_property!pushes onto a bufferedtransform(:987).Fix
to_transformhelpers lose their only caller. The change removes them.test/js/bun/css/css.test.ts(24 cases fail on main). Alsotest/bundler/cssandtest/bundler/esbuild/css.test.ts. Self-reviewed: 1 concern raised, 1 addressed (Notes).Background
flushprints them.translate,rotateandscaleare separate properties (CSS Transforms Level 2). They are not longhands oftransform.transformin the right order (the old TODO in the tests). It is wrong when another rule overrides one property, so upstream dropped it too.Downsides
transformand one of the three now prints each declaration. The folded output was shorter. 0 of 4,929 real stylesheets change..textshrinks by 1,024 B.bun_cssruns 2,760 fewer instructions over the 15 in-tree stylesheets.Notes
Reproduce
.a{transform:rotate(10deg)}.b{transform:rotate(10deg)translate(10px)}.c{transform:translate(0,0)}.a,.b{transform:rotate(10deg);translate:10px}.c{transform:none;translate:none}The result does not depend on browser targets. On main,
.aloses the translation,.btranslates along the rotated axis (the source translates along the page axis), and.csets a transform where the source sets none.Upstream
individual transformstest block is a port of its tests.rotate: 0degin the expected output. They aretest.todohere: bun printsrotate: 0degasrotate: none. css: keep rotate: 0deg out of none, and keep the origin alpha in relative colors #38486 changes that print. css: keep rotate: 0deg out of none, and keep the origin alpha in relative colors #38486 also editsRotate::to_transform, which this PR removes. The PR that lands second drops that helper.Existing expectations
Two existing expectations in the
transformblock change, and one commented-out case is active again:translate: calc(50% - 100px + 20px) 0px; transform: translate(2px, 3px)now keepstranslate.scale: 0.5; transform: scale(3)now keepsscale.transform: scale(3); scale: 0.5printstransform:scale(3);scale:.5.Measurements
bun run build:release) of 772f87f, with and without this change tosrc/css. Main has nosrc/csschange between that commit and the merge base..text: 79,755,685 B to 79,754,661 B. The one symbol that changes isTransformHandler::handle_property: 2,397 B to 1,446 B.bun_csssymbols, for one pass over the 15 stylesheets (45,894 declarations): 581,796,845 to 581,794,085. Counted from aqemu-x86_64 -d exec,nochainlog, weighted by the instructions of each translation block.perfandvalgrindare not available on the machine..cssfile of 175 npm packages (4,914 files) and the 15 intest/js/bun/css/files, with the default browser targets and with no targets. No output changes.Suites
test/js/bun/css/css.test.ts: 1,314 pass, 0 fail. On main: 24 fail.test/js/bun/css,test/bundler/css,test/bundler/esbuild/css.test.tsand the CSS regression tests 25785, 25794 and 27458 pass on the debug build, with one exception: two tests innested-selector-expansion.test.tshit the 5 s timeout. They do the same on a debug build of main.css-fuzz.test.tsandnested-vendor-prefix-duplication.test.ts. Both time out on a debug build of main.