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

cdoublev has just created a new issue for https://github.com/w3c/csswg-drafts:

== [cssom] Should `insertRule()` return or throw a syntax error? ==
https://drafts.csswg.org/cssom-1/#dom-cssstylesheet-insertrule

  > 3. Let `parsed rule` be the return value of invoking parse a rule with `rule`.
  > 4. 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:

```js
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?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9234 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 24 August 2023 05:12:37 UTC