Problem with Arguments inheriting from Array

Juriy Zaytsev kangax.dev at gmail.com
Mon Aug 17 16:14:24 PDT 2009


On Aug 17, 2009, at 7:08 PM, Oliver Hunt wrote:

> I implement the logic to make the Arguments object inherit from  
> Array in WebKit last friday and it's quickly turned up a severe  
> incompatibility with Prototype.js, specifcally Prototype's isArray  
> function:
>   isArray: function(object) {
>     return object != null && typeof object == "object" &&
>       'splice' in object && 'join' in object;
>   }
> This breaks at the very least a number of Apple sites and Nasa.gov  
> -- that's just two of the top row of sites on http://www.prototypejs.org/real-world 
> , other sites didn't appear to be broken but then i was merely  
> looking at loading the front page, nothing more.
>
> Unfortunately the use of 'in' means we also can't just shadow a less  
> useful function with null or undefined for now.
>
> Due to these site breakages, caused by a major compatibility problem  
> in a fairly major library it seems infeasible to attempt to retrofit  
> array like behaviour onto arguments.

We actually don't do duck-typing anymore, starting from 1.6.1  
(currently RC3), and instead compare [[Class]] with "Array".  
Unfortunately, currently stable release - 1.6.0.3 - still has `in` in  
its `isArray`.

-- 
kangax
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es5-discuss/attachments/20090817/e5b54e47/attachment.html>


More information about the es5-discuss mailing list