- From: Johannes Koch via GitHub <sysbot+gh@w3.org>
- Date: Thu, 24 Aug 2017 11:51:31 +0000
- To: public-css-archive@w3.org
I suggest something like the following: **old** To **_insert a CSS rule_** _rule_ in a CSS rule list _list_ at index _index_, follow these steps: 1. Set _length_ to the number of items in _list_. 2. If _index_ is greater than _length_, then throw an `IndexSizeError` exception. 3. Set _new rule_ to the results of performing [parse a CSS rule] on argument _rule_. 4. If _new rule_ is a syntax error, throw a `SyntaxError` exception. 5. If _new rule_ cannot be inserted into list at the zero-index position _index_ due to constraints specified by CSS, then throw a `HierarchyRequestError` exception. [CSS21] Note: For example, a CSS style sheet cannot contain an `@import` at-rule after a style rule. 6. If _new rule_ is an `@namespace` at-rule, and _list_ contains anything other than `@import` at-rules, and `@namespace` at-rules, throw an `InvalidStateError` exception. 7. Insert _new rule_ into _list_ at the zero-indexed position _index_. 8. Return _index_. --- **new** To **_insert a CSS rule_** created from a string _string_ in a CSS rule list _list_ at index _index_, follow these steps: 1. Set _length_ to the number of items in _list_. 2. If _index_ is greater than _length_, then throw an `IndexSizeError` exception. 3. Set _new rule_ to the results of performing [parse a CSS rule] on argument _string_. 4. If _new rule_ is a syntax error, throw a `SyntaxError` exception. 5. Run the [insert a new CSS rule] steps with _new rule_ at index _index_. 6. Return _index_. To **_insert a new CSS rule_** _new rule_ in a CSS rule list _list_ at index _index_, follow these steps: Note: _index_ should already not be greater than the number of items in _list_. 1. If _new rule_ cannot be inserted into _list_ at the zero-index position _index_ due to constraints specified by CSS, then throw a `HierarchyRequestError` exception. [CSS21] Note: For example, a CSS style sheet cannot contain an `@import` at-rule after a style rule. 2. If _new rule_ is an `@namespace` at-rule, and _list_ contains anything other than `@import` at-rules, and `@namespace` at-rules, throw an `InvalidStateError` exception. 3. Insert _new rule_ into _list_ at the zero-indexed position _index_. 4. Return _index_. To **_initially add CSS rules_** from a list of (css-syntax) rules _rules_ to a CSS rule list _list_, follow these steps: 1. For each (css-syntax) rule _rule_ in _rules_, follow these substeps: 1. Let _parsed rule_ be the result of parsing _rule_ according to the appropriate CSS specifications, dropping parts that are said to be ignored. If the whole rule is dropped, return a syntax error. (see step in **_parse a CSS rule_**) 2. Let _index_ be the number of items in _list_. 3. Run the [insert a new CSS rule] steps with _parsed rule_ at _index_. To **_initially add CSS rules into a CSS stylesheet's CSS rule list_** _list_, follow these steps: 1. Let _stylesheet_ be the result of performing [parse a stylesheet]. 2. Let _rules_ be the _stylesheet_'s value. 3. Run the [initially add CSS rules] steps with _rules_ and _list_. To **_initially add CSS rules into a CSS rule's CSS rule list_** _list_, follow these steps: 1. Let _rules_ be the result of performing [parse a list of rules]. 2. Run the [initially add CSS rules] steps with _rules_ and _list_. -- GitHub Notification of comment by waldbaerkoch Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1754#issuecomment-324613466 using your GitHub account
Received on Thursday, 24 August 2017 11:51:29 UTC