From cda9099a210e27c49b367b3839bef76e49d6b386 Mon Sep 17 00:00:00 2001 From: Jeremy Ashkenas Date: Sat, 9 Jan 2010 19:34:32 -0500 Subject: [PATCH] Underscore 0.5.5, with a fix for OOP-wrapping in MobileSafari, thanks to terrcin. --- index.html | 9 +++++++-- underscore-min.js | 6 +++--- underscore.js | 7 ++++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index e2f483136..34378d703 100644 --- a/index.html +++ b/index.html @@ -113,11 +113,11 @@

- + - +
Development Version (0.5.4)Development Version (0.5.5) 22kb, Uncompressed with Comments
Production Version (0.5.4)Production Version (0.5.5) 3kb, Packed and Gzipped
@@ -1067,6 +1067,11 @@ _([1, 2, 3]).value();

Change Log

+

+ 0.5.5
+ Fix for a bug in MobileSafari's OOP-wrapper, with the arguments object. +

+

0.5.4
Fix for multiple single quotes within a template string for diff --git a/underscore-min.js b/underscore-min.js index e97a8b7d9..9146e0860 100644 --- a/underscore-min.js +++ b/underscore-min.js @@ -1,4 +1,4 @@ -(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.4";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)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){o.call(arguments, -this._wrapped);return l(c.apply(b,arguments),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})(); +" ").replace(/'(?=[^%]*%>)/g,"\t").split("'").join("\\'").split("\t").join("'").replace(/<%=(.+?)%>/g,"',$1,'").split("<%").join("');").split("%>").join("p.push('")+"');}return p.join('');");return c?a(c):a};b.forEach=b.each;b.foldl=b.inject=b.reduce;b.foldr=b.reduceRight;b.filter=b.select;b.every=b.all;b.some=b.any;b.head=b.first;b.tail=b.rest;b.methods=b.functions;var l=function(a,c){return c?b(a).chain():a};b.each(b.functions(b),function(a){var c=b[a];i.prototype[a]=function(){var d=b.toArray(arguments); +o.call(d,this._wrapped);return l(c.apply(b,d),this._chain)}});b.each(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){c.apply(this._wrapped,arguments);return l(this._wrapped,this._chain)}});b.each(["concat","join","slice"],function(a){var c=Array.prototype[a];i.prototype[a]=function(){return l(c.apply(this._wrapped,arguments),this._chain)}});i.prototype.chain=function(){this._chain=true;return this};i.prototype.value=function(){return this._wrapped}})(); diff --git a/underscore.js b/underscore.js index a29fdc4e0..4385967c6 100644 --- a/underscore.js +++ b/underscore.js @@ -38,7 +38,7 @@ propertyIsEnumerable = Object.prototype.propertyIsEnumerable; // Current version. - _.VERSION = '0.5.4'; + _.VERSION = '0.5.5'; // ------------------------ Collection Functions: --------------------------- @@ -600,8 +600,9 @@ _.each(_.functions(_), function(name) { var method = _[name]; wrapper.prototype[name] = function() { - unshift.call(arguments, this._wrapped); - return result(method.apply(_, arguments), this._chain); + var args = _.toArray(arguments); + unshift.call(args, this._wrapped); + return result(method.apply(_, args), this._chain); }; });