Skip to content

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

Closed
@upsuper

Description

@upsuper

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 and bug 1460295 related to this issue.

It seems Blink currently appends declaration when it's changing the value, and does nothing otherwise.

If we want to go that way, for the issue raised in #1898, it means although code like

elem.style.marginTop = "1px";
elem.style.marginBlockStart = "2px";
elem.style.marginTop = "0px";

would still work as expected, but something like

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions