https://drafts.csswg.org/css-text-3/#propdef-word-wrap
The spec says:
For legacy reasons, UAs must treat word-wrap as an alternate name for the overflow-wrap property, as if it were a shorthand of overflow-wrap.
The "as if it were a shorthand" is a bit hand-wavy, especially since "as an alternate name" can mean something else.
In particular, we have two different ways of "aliasing" properties. One is by making them shorthands of the aliasee. The other is by making them redirect to the other property at parse time.
The difference crops up when doing things like serializing property declaration blocks. For example, the following CSS:
#foo {
word-wrap: break-word;
overflow-wrap: break-word;
align-items: flex-end;
-webkit-align-items: baseline;
foobar: baz;
}
when serialized via document.styleSheets[0].cssRules[0].cssText in Firefox produces "#foo { overflow-wrap: break-word; align-items: baseline; }", whereas in Chrome/Safari it produces "#foo { word-wrap: break-word; overflow-wrap: break-word; align-items: baseline; }". This means that Firefox implements it as a "redirect alias", but Chrome/Safari implement it as a shorthand alias. All of them handle -webkit-align-items as a "redirect alias".
Browsers already use "redirect aliases" consistently for aliasing legacy prefixed properties. This concept of an alias is not defined in the spec, but is consistently implemented in browsers as something akin to:
If foo is an alias for property bar:
- At parse time, if you encounter a property of name
foo, treat it as if it were the name you encountered was of property bar
- In CSSStyleDeclaration add accessors for the alias
foo that under the hood work with property bar
- Nowhere else should there be traces of the name
foo (including during serialization of a declaration block)
The compat spec uses this concept of "aliasing", but does not define it.
We should either explicitly spec word-wrap to be a shorthand, or define this other concept of property alias in the spec and use it here (and also use it in the compat spec). I personally prefer the latter solution since aliasing is currently unspecced but imo shouldn't be, and because this is the only case where a shorthand is used for aliasing.
cc @dholbert @dbaron @fantasai
https://drafts.csswg.org/css-text-3/#propdef-word-wrap
The spec says:
The "as if it were a shorthand" is a bit hand-wavy, especially since "as an alternate name" can mean something else.
In particular, we have two different ways of "aliasing" properties. One is by making them shorthands of the aliasee. The other is by making them redirect to the other property at parse time.
The difference crops up when doing things like serializing property declaration blocks. For example, the following CSS:
when serialized via
document.styleSheets[0].cssRules[0].cssTextin Firefox produces"#foo { overflow-wrap: break-word; align-items: baseline; }", whereas in Chrome/Safari it produces"#foo { word-wrap: break-word; overflow-wrap: break-word; align-items: baseline; }". This means that Firefox implements it as a "redirect alias", but Chrome/Safari implement it as a shorthand alias. All of them handle-webkit-align-itemsas a "redirect alias".Browsers already use "redirect aliases" consistently for aliasing legacy prefixed properties. This concept of an alias is not defined in the spec, but is consistently implemented in browsers as something akin to:
If
foois an alias for propertybar:foo, treat it as if it were the name you encountered was of propertybarfoothat under the hood work with propertybarfoo(including during serialization of a declaration block)The compat spec uses this concept of "aliasing", but does not define it.
We should either explicitly spec
word-wrapto be a shorthand, or define this other concept of property alias in the spec and use it here (and also use it in the compat spec). I personally prefer the latter solution since aliasing is currently unspecced but imo shouldn't be, and because this is the only case where a shorthand is used for aliasing.cc @dholbert @dbaron @fantasai