All browsers seem to agree on setting a rule's parentStyleSheet to null when its ancestor rule is removed, but the procedure to remove a CSS rule only dereference the parent style sheet on the removed rule.
- Set
old rule’s parent CSS rule and parent CSS style sheet to null.
https://drafts.csswg.org/cssom-1/#remove-a-css-rule
I suggest this addition:
- If
old rule has child rules, remove those rules from rules
Details
const sheet = new CSSStyleSheet
sheet.replaceSync('@keyframes test { to {} }')
const rule = sheet.cssRules[0]
const nested = rule.cssRules[0]
sheet.replaceSync('')
rule.parentStyleSheet // null
nested.parentStyleSheet // null
All browsers seem to agree on setting a rule's
parentStyleSheettonullwhen its ancestor rule is removed, but the procedure to remove a CSS rule only dereference the parent style sheet on the removed rule.https://drafts.csswg.org/cssom-1/#remove-a-css-rule
I suggest this addition:
Details