Ticket #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: | ||
| 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
Change History
Changed 3 years ago by hitsthings
-
attachment
Default.html
added
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];
};
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Sample page