Re: [csswg-drafts] [css-logical] Flow-relative syntax for `margin`-like shorthands

> A third option would be to have some other not-currently-used single punctuation character somewhere in the declaration, to indicate flow-relative mapping

The problem is that this could be used in stylesheets but not in CSSOM. I prefer a keyword specified as part of the value.

In fact I'm a bit concerned about the CSSOM implications of this thread, which haven't been discussed. Currently the `margin` shorthand only has the physical longhands, but with this feature `margin` would also map to the logical longhands.

[CSSOM shorthand serialization](https://drafts.csswg.org/cssom/#serialize-a-css-value) says
> If [...] shorthand cannot exactly represent the values of all the properties in list, return the empty string.

This means that `margin` could only be serialized if only the physical longhands are set and the logical ones are not (or viceversa). But this doesn't seem much intuitive to me:

```js
element.style.margin = "1px 2px 3px 4px";
element.style.margin = "logical 5px 6px 7px 8px";
element.style.margin; // ""
```

the first line sets the physical ones, the second line the logical ones, and then the shorthand cannot represent a combination of both and serializes to the empty string. I would expect to get the most recently assigned value.

So maybe `element.style.margin = "logical 5px 6px 7px 8px"` should remove the previous declarations of the physical longhands? They will be overridden anyway (unless they are important). Or maybe the serialization algorithm should serialize shorthands with both logical and physical longhands if all the logical ones are set and have more precedence than the physical ones (if any), or viceversa. 


-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1282#issuecomment-432138499 using your GitHub account

Received on Tuesday, 23 October 2018 08:00:09 UTC