From d030b8d76412a7b4f77044d57de8e56569b979d2 Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 21 Aug 2014 13:05:27 +0200 Subject: [PATCH] Ox.values: make sure that for nodelists, this returns an array, not a nodelist; Ox.contains: make sure this works for nodelists too --- source/Ox/js/Collection.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/Ox/js/Collection.js b/source/Ox/js/Collection.js index a2b41404..53e66e09 100644 --- a/source/Ox/js/Collection.js +++ b/source/Ox/js/Collection.js @@ -59,10 +59,11 @@ Ox.contains Tests if a collection contains a value > Ox.contains('foobar', 'bar') true @*/ -// FIXME: a shorter name would be nice (but IE8 doesn't like 'in') Ox.contains = function(collection, value) { + var type = Ox.typeOf(collection); return ( - Ox.isObject(collection) ? Ox.values(collection) : collection + type == 'nodelist' || type == 'object' + ? Ox.values(collection) : collection ).indexOf(value) > -1; }; @@ -581,7 +582,7 @@ Ox.values Returns the values of a collection Ox.values = function(collection) { var ret, type = Ox.typeOf(collection); if (type == 'array' || type == 'nodelist') { - ret = Ox.clone(collection); + ret = Ox.slice(collection); } else if (type == 'object' || type == 'storage') { ret = []; Ox.forEach(collection, function(value) {