- From: Daniel Holbert via GitHub <sysbot+gh@w3.org>
- Date: Wed, 07 Jun 2017 20:01:59 +0000
- To: public-css-archive@w3.org
Possibly-more-direct testcase: ```` <style id="styles"> div { font-family: AAA } </style> <script> var rule = document.getElementById("styles").sheet.cssRules[0]; var styleCopy = rule.style; // THE QUESTION: How "live" is styleCopy? console.log("Initial: " + styleCopy.fontFamily); // Tweak rule.style.* and see if it's visible in styleCopy: rule.style.fontFamily = "BBB"; console.log("After tweaking rule.style.fontFamily: " + styleCopy.fontFamily); // Tweak rule.style itself, and see if it's visible in styleCopy: rule.style = "font-family: CCC"; console.log("After tweaking rule.style: " + styleCopy.fontFamily); // Clear rule.style and see if it's visible in styleCopy: rule.style = ""; console.log("After clearing rule.style: " + styleCopy.fontFamily); </script> ```` In Firefox 55 Nightly & Chrome Dev 60, this outputs: > Initial: AAA > After tweaking rule.style.fontFamily: BBB > After tweaking rule.style: CCC > After clearing rule.style: In Safari 10.1 & Edge 15, this instead outputs: > Initial: AAA > After tweaking rule.style.fontFamily: BBB > After tweaking rule.style: BBB > After clearing rule.style: BBB The last two lines are where we differ -- specifically, browsers disagree about what happens when you adjust the value of `CSSStyleRule.style` (though they agree on what happens when `CSSStyleRule.style.whatever` is tweaked.) * In Firefox & Chrome, `CSSStyleRule.style` seems to be a reference to an object, and if you reassign it, you're updating the contents of that object (which is reflected in variables that were set to the original value). * In Edge & Safari, `CSSStyleRule.style` behaves more like a *pointer* to an object, and reassignment will simply change `CSSStyleRule.style` to point somewhere else (and that change is *not* reflected in variables that were set to the original value). -- GitHub Notification of comment by dholbert Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1506#issuecomment-306908360 using your GitHub account
Received on Wednesday, 7 June 2017 20:02:05 UTC