Bug Tracker

Modify

Ticket #11998 (closed feature: wontfix)

Opened 11 months ago

Last modified 11 months ago

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

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.

Last edited 11 months ago by rwaldron (previous) (diff)

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.

comment:3 Changed 11 months ago by rwaldron

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

comment:4 Changed 11 months ago by anonymous

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.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.