Permalink
Browse files

Merge pull request #38 from rvagg/firstlast

first()/last() safety for empty sets
  • Loading branch information...
2 parents 1a69556 + 8bbe904 commit 203aaf8531a2c6efbf26d556d76644f1d18f6888 @ded ded committed Oct 17, 2011
Showing with 4 additions and 4 deletions.
  1. +2 −2 src/bonzo.js
  2. +2 −2 src/ender.js
View
@@ -227,11 +227,11 @@
}
, first: function () {
- return bonzo(this[0])
+ return bonzo(this.length ? this[0] : [])
}
, last: function () {
- return bonzo(this[this.length - 1])
+ return bonzo(this.length ? this[this.length - 1] : [])
}
, html: function (h, text) {
View
@@ -55,11 +55,11 @@
},
first: function () {
- return $(this[0])
+ return $(this.length ? this[0] : this)
},
last: function () {
- return $(this[this.length - 1])
+ return $(this.length ? this[this.length - 1] : [])
},
next: function () {

0 comments on commit 203aaf8

Please sign in to comment.