[csswg-drafts] [cssom] We may not want .setProperty() to change the order if it's setting an identical value to an existing declaration

upsuper has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom] We may not want .setProperty() to change the order if it's setting an identical value to an existing declaration ==
So in #1898, we resolved to have `.setProperty()` behave like appending rather than changing in-place. It causes problem that browsers become unable to optimize out setting identical values. When that happens in inline style, that can consequently trigger mutation event and observer.

>From Gecko we have seen [bug 1449584](https://bugzilla.mozilla.org/show_bug.cgi?id=1449584) and [bug 1460295](https://bugzilla.mozilla.org/show_bug.cgi?id=1460295) related to this issue.

It seems Blink currently [appends declaration when it's changing the value](https://cs.chromium.org/chromium/src/third_party/blink/renderer/core/css/css_property_value_set.cc?l=405-421&rcl=59f892fc9d3c442f4381ebd220658b19644812ba), and does nothing otherwise.

If we want to go that way, for the issue raised in #1898, it means although code like
```javascript
elem.style.marginTop = "1px";
elem.style.marginBlockStart = "2px";
elem.style.marginTop = "0px";
```
would still work as expected, but something like
```javascript
elem.style.marginTop = "1px";
elem.style.marginBlockStart = "2px";
elem.style.marginTop = "1px";
```
would not.

It's not clear to me whether that's something reasonable.

Avoiding changing the declaration block when updating declaration with identical value wouldn't affect fixing #2515, though, which is good.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2667 using your GitHub account

Received on Thursday, 10 May 2018 11:12:19 UTC