Skip to main content

Bug Tracker

Side navigation

#11998 closed feature (wontfix)

Opened July 01, 2012 09:53PM UTC

Closed July 02, 2012 01:17AM UTC

Last modified July 03, 2012 01:26PM UTC

Change array.length check to $.isArray

Reported by: anonymous Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:
Description

I would like to propose changing makeArray to use !$.isArray(array) rather than array.length == null.

The motivation is that I use .on on instances such as file readers or file writers. That way I can take advantage of jQuery's event namespacing system, and it's a clean way of attaching events since I'm using .on for elements as well.

The issue is that FileWriters have a length property and as such jQuery recognises it as an array. Consequently, .on does not work on file writers.

I know $(someFileWriter) is perhaps not what jQuery is for, but I do think it's worth mentioning and hopefully this issue can be addressed. It would be awesome to have jQuery support .on for any instance that has addEventListener so that its event features can be used on those instances.

Attachments (0)
Change History (4)

Changed July 02, 2012 01:17AM UTC by rwaldron comment:1

_comment0: From the docs: \ \ > Description: Convert an array-like object into a true JavaScript array. \ \ FileWriter is not an array-like object.1341191897808770
resolution: → wontfix
status: newclosed

From the docs:

Description: Convert an array-like object into a true JavaScript array.

FileWriter is not an array-like object and the additional function call on the stack is unnecessary.

Changed July 02, 2012 09:20AM UTC by anonymous comment:2

I think you got me wrong.

The source of makeArray actually includes checks for e.g. functions and strings, because they are not array-like yet ''do'' have a length property. I think a similar check could be included to account for instances such as file writers.

I do not think "it's not an array-like object" is a completely valid reason, because the above checks are redundant in that case anyway. Note that I'm not talking about calling makeArray separately, but rather the call that's done when calling jQuery(something). So the change is not docs-related nor should the docs need an update.

Thanks for your response.

Changed July 02, 2012 07:31PM UTC by rwaldron comment:3

There's a difference between testing a unit against primitives and builtins vs host APIs

Changed July 03, 2012 01:26PM UTC by anonymous comment:4

Indeed, that's why I filed this request in the first place :)

Anyway, it doesn't seem like you're too intersted in feedback, so never mind.