[csswg-drafts] [css-nesting-1] Consider using ObservableArray<CSSRule> instead of CSSRuleList (#8350)

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

== [css-nesting-1] Consider using ObservableArray<CSSRule> instead of CSSRuleList ==
https://w3c.github.io/csswg-drafts/css-nesting/#cssom-style

I think this would be nicer as

```webidl
partial interface CSSStyleRule {
  attribute ObservableArray<CSSRule> cssRules;
};
```

This:

* Ensures that `cssRules` has all the nice `Array` methods, e.g. `map()`, `filter()`, etc.
* Removes the confusing `item()` method.
* Allows manipulating the CSS rules using normal array methods, e.g. `rule.cssRules.pop()`, `rule.cssRules.splice(4, 1)`, etc.
* Allows completing replacing the rules list, e.g. `rule.cssRules = [newRule1, newRule2]`.

You could optionally keep `insertRule()` and `deleteRule()`, but they would probably be less necessary. (Although I guess there's no other way to go from string -> `CSSRule`?)

/cc @tabatkins as someone interested in array-like design on the web platform.

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


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

Received on Monday, 23 January 2023 01:18:29 UTC