Skip to content

Commit

Permalink
have get() method accept negative index
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaody authored and mislav committed Dec 12, 2012
1 parent 912793d commit ca7fb89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/zepto.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(){
Expand Down
1 change: 1 addition & 0 deletions test/zepto.html
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ <h1>Zepto DOM unit tests</h1>
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)
},

Expand Down

0 comments on commit ca7fb89

Please sign in to comment.