W3C home > Mailing lists > Public > public-css-archive@w3.org > October 2017

Re: [csswg-drafts] [css-logical-1] [css-cascade-3] The all longhand probably shouldn't set logical properties.

From: Oriol Brufau via GitHub <sysbot+gh@w3.org>
Date: Fri, 27 Oct 2017 19:37:23 +0000
To: public-css-archive@w3.org
Message-ID: <issue_comment.created-340066108-1509133041-sysbot+gh@w3.org>
> this is then serialized to the style attribute in a predefined order (the order you set the properties in doesn't matter)

The order does matter. That's because [set a CSS declaration value](https://drafts.csswg.org/cssom/#set-a-css-declaration-value) uses a "list of declarations", and lists are ordered. The algorithm also says "append", which implies there is an order. (Firefox and Chrome are compliant, but it seems Edge does not respect this insertion order).

The problem is that the algorithm only appends the new declaration if there was no previous declaration of the same property. Otherwise, it only updates the value of the old one, without moving it to the end.

Therefore, if you first set properties using `all` and then set a property to another value, you don't know whether the new value will win the cascade or not, because the order in which `all` inserted declarations into the list does not seem to be defined anywhere.

Additionally, the resulting declarations of the following steps will be

```js
elem.style.marginTop = "1px";        // { margin-top: 1px }
elem.style.marginBlockStart = "2px"; // { margin-top: 1px; margin-block-start: 2px }
elem.style.marginTop = "0px";        // { margin-top: 0px; margin-block-start: 2px }
```
so (assuming `writing-mode: horizontal-tb`) the top margin will end up being `2px` instead of `0px`. Instead, I think it should be


```js
elem.style.marginTop = "1px";        // { margin-top: 1px }
elem.style.marginBlockStart = "2px"; // { margin-top: 1px; margin-block-start: 2px }
elem.style.marginTop = "0px";        // { margin-block-start: 2px; margin-top: 0px }
```

-- 
GitHub Notification of comment by Loirooriol
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1898#issuecomment-340066108 using your GitHub account
Received on Friday, 27 October 2017 19:37:26 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:19 UTC