git.asbjorn.biz
/
jquery.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e124fec
)
Add support for .get(-Number) Closes #4188
author
Yehuda Katz
<wycats@gmail.com>
Thu, 16 Jul 2009 07:31:41 +0000
(07:31 +0000)
committer
Yehuda Katz
<wycats@gmail.com>
Thu, 16 Jul 2009 07:31:41 +0000
(07:31 +0000)
src/core.js
patch
|
blob
|
history
test/unit/core.js
patch
|
blob
|
history
diff --git
a/src/core.js
b/src/core.js
index
35e6e34
..
1721bda
100644
(file)
--- a/
src/core.js
+++ b/
src/core.js
@@
-130,10
+130,10
@@
jQuery.fn = jQuery.prototype = {
return num == null ?
// Return a 'clean' array
return num == null ?
// Return a 'clean' array
- Array.prototype.slice.call( this ) :
+ this.toArray() :
// Return just the object
// Return just the object
- this[ num ];
+ ( num < 0 ? this.toArray.call(this, num)[0] : this[ num ] );
},
// Take an array of elements and push it onto the stack
},
// Take an array of elements and push it onto the stack
diff --git
a/test/unit/core.js
b/test/unit/core.js
index
aad9e6e
..
05c512b
100644
(file)
--- a/
test/unit/core.js
+++ b/
test/unit/core.js
@@
-340,6
+340,13
@@
test("get(Number)", function() {
equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
});
equals( jQuery("p").get(0), document.getElementById("firstp"), "Get A Single Element" );
});
+test("get(-Number)",function() {
+ expect(1);
+ equals( jQuery("p").get(-1),
+ document.getElementById("first"),
+ "Get a single element with negative index" )
+})
+
test("add(String|Element|Array|undefined)", function() {
expect(12);
isSet( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );
test("add(String|Element|Array|undefined)", function() {
expect(12);
isSet( jQuery("#sndp").add("#en").add("#sap").get(), q("sndp", "en", "sap"), "Check elements from document" );