Skip to content
Browse files

have get() method accept negative index

  • Loading branch information...
1 parent 912793d commit ca7fb895a356bc8f6046a1bfe82a7fb2f685270d @xiaody xiaody committed with mislav
Showing with 2 additions and 1 deletion.
  1. +1 −1 src/zepto.js
  2. +1 −0 test/zepto.html
View
2 src/zepto.js
@@ -337,7 +337,7 @@ var Zepto = (function() {
return this
},
get: function(idx){
- return idx === undefined ? slice.call(this) : this[idx]
+ return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length]
},
toArray: function(){ return this.get() },
size: function(){
View
1 test/zepto.html
@@ -492,6 +492,7 @@
var zepto = $('#find1 .findme')
var outofbounds = zepto.get(zepto.size())
t.assertEqual(zepto.get(0), zepto[0])
+ t.assertEqual(zepto.get(-1), zepto[zepto.length - 1])
t.assertUndefined(outofbounds)
},

0 comments on commit ca7fb89

Please sign in to comment.
Something went wrong with that request. Please try again.