Bug Tracker

Opened 10 years ago

Closed 10 years ago

#5605 closed bug (invalid)

.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:
Blocked by: Blocking:

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 (1)

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

Download all attachments as: .zip

Change History (5)

Changed 10 years ago by hitsthings

Attachment: Default.html added

Sample page

comment:1 Changed 10 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 10 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 10 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 10 years ago by dmethvin

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.