[Bug 27384] CSSStyleSheet.insertRule's index argument should be optional with default 0

https://www.w3.org/Bugs/Public/show_bug.cgi?id=27384

--- Comment #2 from Boris Zbarsky <bzbarsky@mit.edu> ---
> so maybe it's on WebKit-specific paths

I read through https://code.google.com/p/chromium/issues/detail?id=319695
(again; when I got to the end it became clear I'd done that before) and it
looks like the instances there were all on WebKit-specific paths. 
Specifically, all of the reports seemed to be from a single jQuery plugin that
uses dynamically-inserted CSS animation rules, but only if
style.WebkitAnimationName tests not undefined (conveniently using a slower
codepath in other browsers, yay.  :( ).

_If_ Chrome is planning to ever remove style.WebkitAnimationName, that would
automatically fix the issue with this library.  I don't think it makes much
sense to talk about use counters until that happens.  I did mention this in
https://code.google.com/p/chromium/issues/detail?id=319695#c34 which got
summarily ignored.

Past that, I'm pretty loath to make this argument non-optional because then
people would be more likely to use it without the second argument (implying 0),
and the behavior of Chrome and other browsers differs wildly when the second
argument is 0.  Specifically, because Chrome doesn't represent @namespace and
@charset rules in the CSSOM at all, as far as I can tell, so insertion at index
0 would work in Chrome in stylesheets that use those but not @import rules,
while they would fail in Firefox and IE (or at least fail in the @namespace
case in IE; IE seems to not represent @charset in the CSSOM).

This interaction with @-rules means that insertRule at 0 is a huge footgun. 
>From an API design standpoint, I would be much happier if we had an appendRule
on CSSStyleSheet, because that would actually be safe to call, unlike
insertRule(..., 0).

Back to the original question, though, I guess I'd be ok with doing it if
browsers first align on the cases in which insertRule() throws.  Otherwise it
feels like we're promoting a pattern which throws in some but not all browsers
in very non-obvious ways...

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 21 November 2014 15:33:07 UTC