This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 17520 - does not specify how to handle multiple rules on insertRule
Summary: does not specify how to handle multiple rules on insertRule
Alias: None
Product: CSS
Classification: Unclassified
Component: CSSOM (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: ---
Assignee: Simon Pieters
QA Contact: public-css-bugzilla
Depends on:
Reported: 2012-06-16 22:44 UTC by Andrew Hushbeck
Modified: 2013-08-08 13:26 UTC (History)
2 users (show)

See Also:


Description Andrew Hushbeck 2012-06-16 22:44:04 UTC
When doing an insertRule call on a CSSStyleSheet, the spec does not specify what to do if the rule contains multiple valid rules. It simple says:

    Parse rule.

    If parsing failed terminate these steps.

With multiple valid rules, theoretically parsing will succeed, but there is no indication if it is valid to have multiple rules in the string. Currently, IE 9, Chrome 19, and Opera 11.6 throw SYNTAX_ERR, whereas Firefox only inserts the first rule into the page.

This should probably be clarified to throw an error if more than 1 rule exists.
Comment 1 L. David Baron (Mozilla) 2013-02-09 06:46:37 UTC
Quoting the css3-conditional disposition of comments (so far) on the analogous issue in that spec:

Issue 5:
Issue in spec about insertRule, followup to Issue 7
also raised as first issue in
Raised by: David Baron, Florian Rivoal
Proposed resolution:
Florian agrees:
(Commenter agrees, of course.)
Comment 2 L. David Baron (Mozilla) 2013-02-09 06:47:12 UTC
(And I'm changing Firefox's behavior in .)
Comment 3 Simon Pieters 2013-06-27 12:58:25 UTC
This was fixed as part of integration with css-syntax. If you have multiple rules, css-syntax returns a syntax error:

If the current input token is an 〈EOF〉, return the rule obtained in step 2. Otherwise, return a syntax error.

and CSSOM then throws SyntaxError:

If new rule is a syntax error, throw a SyntaxError exception.