Skip to content

[cssom] CSSStyleRule.style assignability (?) differs across browsers #1506

Closed
@jyc

Description

@jyc

EDIT: It seems like the difference arises due to Safari and Edge not implementing PutForwards, which is an attribute on the style field of CSSStyleRule (https://drafts.csswg.org/cssom/#the-cssstylerule-interface).


Is CSSStyleRule.style supposed to be live (if that's the right term)? In Firefox and Chrome, the following example will output "", while in Safari it will output "3px":

<style id="styles">
div { margin: 10px; }
</style>

<script>
var style = document.getElementById("styles").sheet;
var ruleList = style.cssRules;
var rule = ruleList[0];

rule.style.margin = "3px";

//console.log("before " + rule.style.margin);
// in all browsers, this is '3px'

// this is what assert_readonly in testharness.js does
var initial = rule["style"];
rule["style"] = initial + "a";
rule["style"] = initial;

console.log(rule.style.margin);
// in Chrome and Firefox, this is '', while in Safari, this is '3px'

rule.style.margin = "10px";

//console.log("end " + rule.style.margin);
// in all browsers, this is '10px'
</script>

This is sort of a related issue for Typed OM, where the eventual decision was for the corresponding object to be live: w3c/css-houdini-drafts#149

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