Ticket #11998 (closed feature: wontfix)
Change array.length check to $.isArray
| Reported by: | anonymous | Owned by: | |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | git |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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.
Change History
comment:1 Changed 11 months ago by rwaldron
- Status changed from new to closed
- Resolution set to wontfix
comment:2 Changed 11 months ago by anonymous
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

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