On Tue, Jun 19, 2012 at 1:55 PM, David Bruant <[email protected]> wrote: > Le 19/06/2012 18:21, Erik Arvidsson a écrit : >> On Tue, Jun 19, 2012 at 6:42 AM, 程劭非 <[email protected]> wrote: >>> I guess we can try to push Web IDL to do this. >> WebIDL provides [ArrayClass] and DOM4 make NodeLists ArrayClass. This >> means that NodeLists have Array.prototype on its prototype chain. > Excellent! I hadn't heard of that. > >> We tried to make this change in WebKit but it caused some issues, >> mostly on sites depending on a bug in Closure Library. The Closure bug >> has been fixed but the question is how many other sites out there do >> incorrect detection and therefore assume that anything that is an >> instance of Array is actually a true Array > I'll guess a quantity between "a lot" and "a ridiculous amount". > I read "if(something instanceof Array)" very often when view-sourcing > and they mean "Array.isArray(something)". > A trickier question is: will this code break the NodeLists inherit from > Array.prototype and that's harder to answer.
The case that broke was something like this: if (x instanceof Array) realArray.concat(x); The problem is that concat behaves different when its argument is a real Array ([[Class]] is "Array"). I wonder if we could change concat in such a way that it checks the prototype chain too? -- erik _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

