Repository navigation
--computed: read an auto margin as auto, not the px it resolved to - #81
Merged
Merged
Conversation
The resolved px of an auto margin depends on the layout path (a grid item's reads 0px, a centred block's the centring px), so it showed up as margin-left 60px→0px noise on CSS-only changes. Fixes #75 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
probe()insrc/locate.tsnow records a margin whose computed value (computedStyleMap()) isautoasauto, instead of the pxgetComputedStyleresolved it to. One helper, used by both the--computedwalk and pixel mode'sdomlines. Every other value reads exactly as before, somargin-left 24px→16pxstill reads the same. An accepted entry whosedomnamed anautomargin's px (e.g..container margin-left 60px→0px) no longer matches, sinceelementsis part of the fingerprint: that change is now gone or readsauto→…, so re-accept it if it still shows. No other accepted entry changes.Why
getComputedStylereturns the used value for an auto margin, and that depends on the layout path Chrome takes: a centred block reads the centring px, a grid item with the samemargin: 0 autoreads0pxwhile sitting in the same place. That is the.container margin-left 60px → 0pxnoise in #75. The computed value isautoby spec regardless of layout, so the noise is removed at the read.Now:
autoon both sides: no finding.auto→60px(centring replaced with a fixed margin):margin-left auto→60px, a real CSS change, reported truthfully.automargin whose used value changes because the container narrowed: no margin finding; the width change that caused it is.Why not the issue's "drop the margin change when the box is unchanged" rule
margin-bottommoves only the next sibling (or the parent, or collapses through to the parent's sibling), amargin-righton an inline/flex item moves only the next sibling, amargin-leftunderjustify-content: flex-endmoves only the previous siblings. The element's own box stays put in all of these, so a correct rule has to watch own box + siblings + parent + parent's siblings.Snapshotshape change and a memoized walk incollapseInherited. Theautoread is one helper in one file.If you specifically want the "used position" variant the issue mentions as an alternative, say so; this addresses the cause it works around.
Ceilings: without
computedStyleMap(non-Chromium) values read as px, as today. Pseudo-elements keepgetComputedStyle(nocomputedStyleMapfor them). An over-constrainedmargin-rightthat's reported but ignored still shows; separate ticket if it comes up.How tested
New visual test in
tests/visual/computed.test.ts: samemargin: 0 autoelement in block vs grid layout. Before the fix it reportedmargin-right 590px→0pxandmargin-left 590px→0px; with it, no margin finding and the snapshot readsauto. Control in the same test:margin: 0 60pxon the right reportsauto→60px.typecheck,lint,format:check,npm test(305 pass) andnpm run test:visual(335 pass) all green. Docs:docs/output.mdandskills/renderdiff/reference.md.Fixes #75
🤖 Generated with Claude Code