[csswg-drafts] [css-animations-1] Clarify Keyframes.appendRule() and Keyframes.deleteRule() (#6972)

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

== [css-animations-1] Clarify Keyframes.appendRule() and Keyframes.deleteRule() ==
> **5.3.3. The appendRule method**
> 
> The `appendRule` method appends the passed `CSSKeyframeRule` at the end of the keyframes rule.

The web IDL definition of `CSSKeyframesRule.appendRule(rule)` defines `rule` as a `CSSOMString`, not as a  `CSSKeyframeRule`. I assume that `rule` *represents* a `CSSKeyframeRule` resulting from invoking [parse a CSS rule](https://drafts.csswg.org/cssom/#parse-a-css-rule) with `rule`, and that *keyframes rule* is `CSSKeyframes.cssRules`, ie. the [child CSS rules](https://drafts.csswg.org/cssom-1/#concept-css-rule-child-css-rules).

Based on eg. `CSSGroupingRule`, `CSSNestingRule`, etc... I think it could be: 

```diff
- The `appendRule` method appends the passed `CSSKeyframeRule` at the end of the keyframes rule.
+ The `appendRule` method must return the result of invoking [insert a CSS rule](https://drafts.csswg.org/cssom/#insert-a-css-rule) `rule` into the next index `index` of the [child CSS rules](https://drafts.csswg.org/cssom-1/#concept-css-rule-child-css-rules).
```

Note that this change would report a parse error for an invalid keyframe `rule`. Alternatively, **append a CSS rule* could be defined in CSSOM.

**Side note:** I assume that even if it is not defined in *parse a CSS rule*, the latter should return an instance of a `CSSRule` subclass, and eventually receive an instance of a `CSSStyleSheet` and another `CSSRule` subclass to be referenced from `CSSRule.parentStyleSheet` and `CSSRule.parentRule`, respectively.

> **5.3.4. The deleteRule method**

Based on the above suggestions:

```diff
- The `deleteRule` method deletes the last declared `CSSKeyframeRule` matching the specified keyframe selector. If no matching rule exists, the method does nothing.
+ The `deleteRule` method must invoke [remove a CSS rule](https://drafts.csswg.org/cssom/#remove-a-css-rule) with the index `index` of the last [child CSS rules](https://drafts.csswg.org/cssom-1/#concept-css-rule-child-css-rules) matching the specified keyframe selector. If no matching rule exists, the method does nothing.
```

> 5.3.2. Attributes

```diff
 `cssRules`, of type `CSSRuleList`, readonly
-   This attribute gives access to the keyframes in the list.
+   This attribute gives access to the keyframes in the [child CSS rules](https://drafts.csswg.org/cssom-1/#concept-css-rule-child-css-rules).

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


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

Received on Friday, 21 January 2022 07:46:13 UTC