From 5b5ee87c7a2fa0aa092dc8e87c83973c6c112f4b Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Thu, 28 Jan 2010 00:55:41 -0500 Subject: [PATCH] Underscore 0.5.8, with collection functions that once again work on NodeLists and HTMLCollections --- index.html | 15 ++++++++++++--- test/collections.js | 6 ++++++ underscore-min.js | 10 +++++----- underscore.js | 8 ++++---- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/index.html b/index.html index db2bcaba1..8e26a9659 100644 --- a/index.html +++ b/index.html @@ -111,11 +111,11 @@

- + - +
Development Version (0.5.7)Development Version (0.5.8) 22kb, Uncompressed with Comments
Production Version (0.5.7)Production Version (0.5.8) 3kb, Packed and Gzipped
@@ -1097,10 +1097,19 @@ _([1, 2, 3]).value();

Change Log

+

+ 0.5.8
+ Fixed Underscore's collection functions to work on + NodeLists and + HTMLCollections + once more, thanks to + Justin Tulloss. +

+

0.5.7
A safer implementation of _.isArguments, and a - faster _.isNumber, thanks to + faster _.isNumber,
thanks to Jed Schmidt.

diff --git a/test/collections.js b/test/collections.js index 935edcb95..3759a6495 100644 --- a/test/collections.js +++ b/test/collections.js @@ -44,6 +44,12 @@ $(document).ready(function() { var doubled = _([1, 2, 3]).map(function(num){ return num * 2; }); equals(doubled.join(', '), '2, 4, 6', 'OO-style doubled numbers'); + + var ids = _.map(document.body.childNodes, function(n){ return n.id; }); + ok(_.include(ids, 'qunit-header'), 'can use collection methods on NodeLists'); + + var ids = _.map(document.images, function(n){ return n.id; }); + ok(ids[0] == 'chart_image', 'can use collection methods on HTMLCollections'); }); test('collections: reduce', function() { diff --git a/underscore-min.js b/underscore-min.js index 53145b713..9492ae919 100644 --- a/underscore-min.js +++ b/underscore-min.js @@ -1,8 +1,8 @@ -(function(){var j=this,n=j._,i=function(a){this._wrapped=a},m=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=j._=function(a){return new i(a)};if(typeof exports!=="undefined")exports._=b;var k=Array.prototype.slice,o=Array.prototype.unshift,p=Object.prototype.toString,q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;b.VERSION="0.5.7";b.each=function(a,c,d){try{if(a.forEach)a.forEach(c,d);else if(b.isArray(a)||b.isArguments(a))for(var e=0,f=a.length;e=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;g=e.computed&&(e={value:f,computed:g})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};b.each(a,function(f,g,h){g=c?c.call(d,f,g,h):f;gf?1:0}),"value")};b.sortedIndex=function(a,c,d){d=d||b.identity;for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.zip=function(){for(var a=b.toArray(arguments),c=b.max(b.pluck(a,"length")),d=new Array(c),e=0;e