diff: compare the cascade layer order the sheets declare - #295
Open
samoht wants to merge 2 commits into
Open
Conversation
The walk pairs two @layer blocks on their bodies and never reads the order the sheet declares, so dropping a leading `@layer a;` pin - which swaps which of the two layers wins - reads as no difference at all.
A layer's strength comes from where its name is first declared, not from where its rules stand, so two sheets holding the same @layer blocks with the same bodies can resolve a conflict the opposite way. The walk reads the order through Resolve.layer_order, the one the cascade resolves against, and names the layer pairs that swapped.
samoht
force-pushed
the
diff-layer-order-walk
branch
from
August 4, 2026 04:24
983e11c to
7dbf427
Compare
This was referenced Aug 4, 2026
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.
The tree walk paired two
@layerblocks, found their bodies equal and reported nothing — even when the two sheets declare the layers in opposite orders and so resolve a conflict between them the opposite way.@layer a;ahead of a@layer bblock makesathe weaker layer. Drop that one statement andbbecomes weaker instead: the same rules now win differently. The walk read the two sheets as identical.It now compares the declared layer order and names the pairs that swapped:
The order comes from
Resolve.layered_rules, the model that already backscascade_layer_precedence_rank— exposed asResolve.layer_orderrather than written a second time. Layers only one sheet declares are left to the existing added/removed reporting, so the comparison is over the layers both sides have. A layer declared inside@media/@supports/@containeris not part of it, matching whatResolve.layer_ordercounts; that boundary is documented in both mlis.Tests: the case that was pinned as a known gap is now a positive assertion, alongside a nested-sublayer case and a control —
@layer a;@layer b;against@layer a,b;is one order in two spellings and stays quiet.Tree_diff.tgains alayer_orderfield andCss_compare.statsalayer_order_swapscount, so a layer-order-only diff readsChanges: 1 swapped layer pairinstead of falling through to "none classified structurally".