Permalink
Browse files

Fix array-like of length 0 bug.

  • Loading branch information...
1 parent 4844e6b commit 7bcb62e26c7f9afcd3054ed2f92ada67d7e11516 @timoxley committed Nov 20, 2012
Showing with 1 addition and 2 deletions.
  1. +1 −2 index.js
View
3 index.js
@@ -15,14 +15,13 @@ module.exports = function toArray(collection) {
if (Array.isArray(collection)) return collection.slice()
if (typeof collection.length != 'number') return [collection]
if (typeof collection === 'function') return [collection]
- if (collection instanceof NodeList && !collection.length) return []
var arr = []
for (var i = 0; i < collection.length; i++) {
if (collection.hasOwnProperty(i) || i in collection) {
arr.push(collection[i])
}
}
- if (!arr.length) return [collection]
+ if (!arr.length) return []
return arr
}

0 comments on commit 7bcb62e

Please sign in to comment.