This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
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.
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 http://lists.w3.org/Archives/Public/www-style/2013Feb/0228.html Raised by: David Baron, Florian Rivoal Proposed resolution: http://lists.w3.org/Archives/Public/www-style/2013Feb/0229.html Florian agrees: http://lists.w3.org/Archives/Public/www-style/2013Feb/0228.html Edited: http://lists.w3.org/Archives/Public/www-style/2013Feb/0256.html (Commenter agrees, of course.)
(And I'm changing Firefox's behavior in https://bugzilla.mozilla.org/show_bug.cgi?id=765599 .)
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. ]] http://dev.w3.org/csswg/css-syntax/#parse-a-rule0 and CSSOM then throws SyntaxError: [[ If new rule is a syntax error, throw a SyntaxError exception. ]] http://dev.w3.org/csswg/cssom/#insert-a-css-rule