Ticket #272 (closed defect: wontfix)

Opened 1 year ago

Last modified 2 months ago

Show window be arrayLike?

Reported by: morten@barklund.dk Assigned to: somebody
Priority: low Milestone:
Component: component1 Version:
Severity: minor Keywords:
Cc:

Description

Without regard to the reason and only considering the result, does it make sense, that window is array-like?

MochiKit.Base.isArrayLike(window)

This returns true. I can circumvent that easily, but I am pretty sure, that the current result does not makes sense.

The reason is of course, that window.length is a shortcut for accessing window.frames.length. But window is not really iterable in that sense, is it? window.frames is of course, but window really shouldn't be.

Change History

05/19/08 13:22:49 changed by cederberg@gmail.com

  • status changed from new to closed.
  • resolution set to wontfix.

I agree, the result in this case are not the desired one. But there is a reason for calling the function "isArrayLike" instead of "isArray". We can never be 100% sure that the results from isArrayLike() will be correct, since some object might just have a numeric "length" property (or be a function with an "item" property). In order to provide an error-free implementation, we'd need improvements in the JavaScript language to check if an object is indexable or not.

Until then, I'd rather not add further additional checks for odd cases to isArrayLike(). One has to draw the line somewhere, and I just don't see the window object coming in frequently enough to warrant an additional check for that. I'll close this ticket as "wontfix". If you feel otherwise, please discuss on the mailing list.