w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.42k stars 648 forks source link

[cssom] Define "canonical order". #5741

Open emilio opened 3 years ago

emilio commented 3 years ago

CSSOM makes references to "canonical order" in a bunch of places to refer to the order in which a shorthand expands to their longhands.

For example, for:

flex: 0; flex-grow: inherit;

Browsers serialize it as:

flex-shrink: 1; flex-basis: 0%; flex-grow: inherit;

which means that "flex" expands "flex-shrink" before "flex-basis". I don't think that's defined anywhere, and it probably should.

cc @fantasai @tabatkins

cdoublev commented 3 years ago

"[...] reorder the component values to use the canonical order of component values as given in the property definition table

I spent several days on the CSSOM specification and while searching for an issue similar to mine, I remembered this part. Sorry if that doesn't help answer this issue.

Related: #6894.

SamB commented 1 year ago

Hmm. Is that one "canonical order" or two?

Either way, this definitely needs to define the meaning of "Canonical order: per grammar", and if that definition does not work on all possible grammars, you might want some sort of lint to warn you of cases where it doesn't work. For example, does it actually make any sense for https://drafts.csswg.org/css-backgrounds/#propdef-border-width? The grammar isn't particularly complicated, but the mapping to longhand properties is defined in the prose, not the grammar.

Regardless of the above, bikeshed needs a better place to link these table entries to than https://www.w3.org/TR/cssom/#serializing-css-values (added in https://github.com/speced/bikeshed/commit/ed3425a59ec5f546f79b35df2d6e2d84fd3bf94a).