2010/6/18 Michael Ficarra <[email protected]>:
> Is there a plan to fix this or at least a ticket filed? There exists
> some code in mootools that relies on this functionality.

Please file an issue and put Mike Stay (metaw...@gmail) as the owner.


> On Jun 18, 6:25 pm, Mike Samuel <[email protected]> wrote:
>> 2010/6/18 Michael Ficarra <[email protected]>:
>>
>> > I'm not sure what you mean by this. How would this help me practically
>> > determine if one object is an arguments object and one is an
>> > HTMLCollection? If it is possible outside of caja, is there any reason
>> > to break this functionality in cajoled code? As of right now, I
>> > believe it is not possible to differentiate these three native types
>> > of objects within cajoled code, as caja just uses regular arrays to
>> > emulate these objects. This works for most use cases except for the
>> > meta-case of actually determining the type of object, which would
>> > never work while using one object to emulate another.
>>
>> You are right that it is a bug in caja.
>>
>>
>>
>> > On Jun 18, 5:59 pm, Mike Samuel <[email protected]> wrote:
>> >> Yep.  In 10.6 of EcmaScript 5 is
>> >>     4. Set the [[Class]] internal property of obj to "Arguments".
>>
>> >> 2010/6/18 Michael Ficarra <[email protected]>:
>>
>> >> > isArray((function(){ return arguments; })(1,2))
>> >> >  and
>> >> > isArray(document.getElementsByTagName('*'))
>> >> > both return true in cajoled JS. That is the problem. They are not
>> >> > truly arrays and should not inherit the properties of Array.prototype.
>>
>> >> > On Jun 18, 5:20 pm, Mike Samuel <[email protected]> wrote:
>> >> >> 2010/6/18 Michael Ficarra <[email protected]>:
>>
>> >> >> > I am having difficulty distinguishing between arrays and array-like
>> >> >> > objects in cajoled code. It seems that caja does not provide a
>> >> >> > facility to differentiate an arguments object from an array (since it
>> >> >> > does not allow access to the `callee` property for legitimate 
>> >> >> > security
>> >> >> > reasons) or a NodeList from an array, since it only mixes in the
>> >> >> > required `item` method to a standard array. Running the following 
>> >> >> > code
>> >> >> > both cajoled and uncajoled should give more insight into the problem 
>> >> >> > I
>> >> >> > am facing:
>>
>> >> >> > var collection = document.getElementsByTagName('*');
>> >> >> > console.log('collection', collection.constructor !== Array, 'item' in
>> >> >> > collection);
>> >> >> > var args = (function(){ return arguments; })(0,1);
>> >> >> > console.log('arguments', args.constructor !== Array, 'callee' in
>> >> >> > args);
>> >> >> > console.log('array', [].constructor === Array);
>>
>> >> >> > There should be no falsey values logged to the console. This
>> >> >> > difference in how caja treats array-like objects shouldn't cause any
>> >> >> > functional problems other than the loss of the ability to distinguish
>> >> >> > arrays from array-like objects.
>>
>> >> >> > tl;dr How does one distinguish between arrays and array-like objects
>> >> >> > in cajoled code?
>>
>> >> >> function isArray(value) {
>> >> >>   return 'object' == typeof value && value !== null
>> >> >>       && '[object Array]' === Object.prototype.toString.call(value);
>>
>> >> >> }
>>
>> >> >> ?

Reply via email to