Skip to content

diff: skip selector-list factoring in the canonical projection - #215

Open
samoht wants to merge 1 commit into
mainfrom
canonical-skip-factoring
Open

diff: skip selector-list factoring in the canonical projection#215
samoht wants to merge 1 commit into
mainfrom
canonical-skip-factoring

Conversation

@samoht

@samoht samoht commented Jul 29, 2026

Copy link
Copy Markdown
Owner

Selector-list factoring is input-shape dependent: whether a shared declaration can be lifted depends on how the input grouped its selectors, and once lifted, an intervening rule writing the same property can make putting it back unsafe. The canonical projection was therefore not confluent - the same stylesheet written factored and written inline mapped to different forms.

In a Tailwind parity run this showed up as .text-xs\/4 losing a declaration:

tw as authored:  .text-xs\/4{font-size:var(--text-xs);line-height:calc(var(--spacing)*4)}
after optimize:  .text-xs,.text-xs\/4,...{font-size:var(--text-xs)}
                 .text-xs\/4{line-height:calc(var(--spacing)*4)}
after canonical: .text-xs\/4{font-size:var(--text-xs)}
                 .text-xs\/4{line-height:calc(var(--spacing)*4)}
reference:       .text-xs\/4{font-size:var(--text-xs);line-height:calc(var(--spacing)*4)}

expand_lists undoes the grouping but cannot restore the merge, because .text-xs sits between the two rules and writes line-height too. The differ then pairs the first rule and reports the second's declaration as missing. Both sides now canonicalise to the reference's single rule.

Css.optimize gains ?factor (default true); only the canonical projection passes false, so fmt --minify still factors.

Factoring depends on how the input grouped its selectors, so a sheet written factored and one written inline canonicalised to different forms and the differ reported the gap as a missing declaration.
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