-
Notifications
You must be signed in to change notification settings - Fork 779
Closed as duplicate of#13291
Closed as duplicate of#13291
Copy link
Labels
cssom-1Current WorkCurrent Work
Description
Browsers seem to set importRule.styleSheet.parentStyleSheet to null after removing the rule via CSSOM.
Test case
<!DOCTYPE html>
<title>Remove a CSS rule: @import styleSheet unlinking</title>
<style>
@import url("data:text/css,.imported { color: red }");
.local { color: green }
</style>
<pre id="out"></pre>
<script>
const out = document.getElementById("out");
function log(msg) { out.textContent += msg + "\n"; }
// Wait for @import to load
setTimeout(() => {
const sheet = document.styleSheets[0];
const importRule = sheet.cssRules[0];
log("importRule.type = " + importRule.type + " (expecting 3 = IMPORT_RULE)");
log("importRule.styleSheet = " + importRule.styleSheet);
const importedSheet = importRule.styleSheet;
if (!importedSheet) {
log("(imported stylesheet not available, try opening via a local server)");
return;
}
log("");
log("=== Before deleteRule ===");
log("importedSheet.parentStyleSheet = " + importedSheet.parentStyleSheet);
log("importedSheet.ownerRule = " + importedSheet.ownerRule);
sheet.deleteRule(0);
log("");
log("=== After deleteRule ===");
log("importedSheet.parentStyleSheet = " + importedSheet.parentStyleSheet);
log("importedSheet.ownerRule = " + importedSheet.ownerRule);
}, 1000);
</script>However, the only place I can find that nulls out parent CSS style sheet is remove a CSS style sheet. And the only caller of that is some xsl-stylesheet thing.
In particular, remove a CSS rule does not call "remove a CSS style sheet" for @import rules. (It does null out the rule's parent CSS style sheet (something all CSS rules have), but not the rule's "associated CSS style sheet"'s parent CSS style sheet.)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
cssom-1Current WorkCurrent Work