Opened 13 years ago
Closed 13 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)
Change History (5)
Changed 13 years ago by
Attachment: | Default.html added |
---|
comment:1 Changed 13 years ago by
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 13 years ago by
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 13 years ago by
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 13 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Sample page