Skip to content

[cssom-1] CSSStyleSheet.replace[Sync]() should parse rules according to CSS specs #6995

@cdoublev

Description

@cdoublev

I believe that CSSStyleSheet.replace() and CSSStyleSheet.replaceSync() are missing a step to parse the input rules according to the appropriate CSS specifications, similarly as in parse a CSS rule, run by insert a CSS rule, run by CSSStyleSheet.insertRule(). Currently, it only parses against basic syntax rules with parse a list of rules, which would mean that something like @namespace "ns" { color: red } should be added to the CSS rules, which is something that UAs are not doing, obviously.

  1. Let rules be the result of running parse a list of rules from text. If rules is not a list of rules (i.e. an error occurred during parsing), set rules to an empty list.
  2. If rules contains one or more @import rules, remove those rules from rules.
  3. Set sheet’s CSS rules to rules.

https://drafts.csswg.org/cssom/#dom-cssstylesheet-replace
https://drafts.csswg.org/cssom/#synchronously-replace-the-rules-of-a-cssstylesheet

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions