w3c / w3c/csswg-drafts

[css-animations-1] Clarify Keyframes.appendRule() and Keyframes.deleteRule()

Open
#6,972 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

css-animations-1
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

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 with rule, and that keyframes rule is CSSKeyframes.cssRules, ie. the child CSS rules.

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

- 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:

- 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

 `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).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with sections 5.3.2–5.3.4 of the CSS Animations specification and follow the referenced CSSOM algorithms for parsing, inserting, and removing CSS rules. Resolve the appendRule, deleteRule, and cssRules wording, including the proposed alternatives and parent-rule details; done means the specification text has an agreed normative clarification.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
documentation
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.