Skip to content

[cssom] Should insertRule() return or throw a syntax error? #9234

Closed
@cdoublev

Description

@cdoublev

https://drafts.csswg.org/cssom-1/#dom-cssstylesheet-insertrule

  1. Let parsed rule be the return value of invoking parse a rule with rule.
  2. If parsed rule is a syntax error, return parsed rule.

All mainstream browsers do not return a syntax error but throws a SyntaxError DOMException when the result of parse a rule is a syntax error:

try {
  document.styleSheets[0].insertRule(' ')
} catch (error) {
  error.name // SyntaxError
  error // DOMException: Failed to execute 'insertRule' on 'CSSStyleSheet': Failed to parse the rule ' '.
}

Furthermore, the Web IDL definition does not allow to return syntax error:

  unsigned long insertRule(CSSOMString rule, optional unsigned long index = 0);

Should the current procedure be updated to this interopable behavior?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions