Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

have get() method accept negative index

  • Loading branch information...
commit ca7fb895a356bc8f6046a1bfe82a7fb2f685270d 1 parent 912793d
@xiaody xiaody authored mislav committed
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)
},
Please sign in to comment.
Something went wrong with that request. Please try again.