- From: Domenic Denicola via GitHub <noreply@w3.org>
- Date: Sat, 07 Mar 2026 09:13:51 +0000
- To: public-css-archive@w3.org
domenic has just created a new issue for https://github.com/w3c/csswg-drafts:
== Can't find spec support for setting importRule.styleSheet.parentStyleSheet to null after deleting that import rule ==
Browsers seem to set `importRule.styleSheet.parentStyleSheet` to `null` after removing the rule via CSSOM.
<details>
<summary>Test case</summary>
```html
<!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>
```
</details>
However, the only place I can find that nulls out [parent CSS style sheet](https://drafts.csswg.org/cssom/#concept-css-style-sheet-parent-css-style-sheet) is [remove a CSS style sheet](https://drafts.csswg.org/cssom/#remove-a-css-style-sheet). And the only caller of *that* is [some xsl-stylesheet thing](https://drafts.csswg.org/cssom/#ref-for-remove-a-css-style-sheet).
In particular, [remove a CSS rule](https://drafts.csswg.org/cssom/#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"](https://drafts.csswg.org/cssom/#dom-cssimportrule-stylesheet)'s parent CSS style sheet.)
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13612 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Saturday, 7 March 2026 09:13:51 UTC