Skip to content

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

Open
@domenic

Description

@domenic

https://w3c.github.io/csswg-drafts/css-nesting/#cssom-style

I think this would be nicer as

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.

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