Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<title>Setting selectorText does not detach rule</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<style id=sheet>
span {
color: black;
}
</style>
<div>
<span id=span>A</span>
</div>
<script>
test(() => {
let rule = sheet.sheet.cssRules[0];
let style = rule.style;
style.color = 'red';
assert_equals(getComputedStyle(span).color, 'rgb(255, 0, 0)');
rule.selectorText = '#span';
style.color = 'green';
assert_equals(getComputedStyle(span).color, 'rgb(0, 128, 0)');
}, 'Modifying property value invalidates style, even after selectorText mutation');
</script>