Skip to content

[cssom-1] Dereference child rule parentStyleSheet when removing an ancestor rule #14109

Description

@cdoublev

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.

  1. 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:

  1. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions