Bug Tracker

Modify

Ticket #5605 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

.get fails in Chrome, this also affects .add

Reported by: hitsthings Owned by:
Priority: major Milestone: 1.4
Component: unfiled Version: 1.3.2
Keywords: Cc:
Blocking: Blocked by:

Description

The .get function does a check:

num === undefined which is false in Chrome, so it ends up returning thisundefined? instead of an Array slice.

Sample of failure:

<html><head><title>whatever</title>

<script type="text/javascript" src="/JS/jquery-1.3.2.js"></script>

</head> <body>

<a id="id1" /> <a id="id2" />

<script type="text/javascript">

var list = jQuery("#id1"); list.add(jQuery("#id2"));

only alerts id1 list.each(function() {

alert(this.id);

});

empty alert alert(jQuery("#id2").get());

</script>

</body> </html>

Attachments

Default.html Download (439 bytes) - added by hitsthings 3 years ago.
Sample page

Change History

Changed 3 years ago by hitsthings

Sample page

comment:1 Changed 3 years ago by hitsthings

proposed fix: jQuery.fn.get = function(num) {

return arguments.length > 0 ?

Return a 'clean' array

Array.prototype.slice.call(this) :

Return just the object

this[num];

};

comment:2 Changed 3 years ago by hitsthings

errrrr

jQuery.fn.get = function(num) {

return arguments.length == 0 ?

Return a 'clean' array

Array.prototype.slice.call(this) :

Return just the object

this[num];

};

comment:3 Changed 3 years ago by hitsthings

Ah crap..........

I don't know how to close this bug, but it should be closed. I thought add would change the array it's called on, not create a new array. Sorry for the bother.

comment:4 Changed 3 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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.