underscore: Avoid regression and cleanup comments. [jddalton]

This commit is contained in:
John-David Dalton
2011-12-06 01:16:56 -05:00
parent d8d1bd0259
commit 2c5661ebb3
2 changed files with 8 additions and 7 deletions

View File

@@ -262,7 +262,7 @@ $(document).ready(function($, undefined) {
ok(!_.isEqual({a: 1}, {a: 1, b: 2}), "Commutative equality is implemented for objects");
ok(!_.isEqual({x: 1, y: undefined}, {x: 1, z: 2}), "Objects with identical keys and different values are not equivalent");
// Objects with shadowing properties
// Objects with properties that shadow non-enumerable ones.
ok(!_.isEqual({}, {toString: 1}), "Object with custom toString is not equal to {}");
ok(_.isEqual({toString: 1, valueOf: 2}, {toString: 1, valueOf: 2}), "Objects with equivalent shadow properties");

View File

@@ -25,8 +25,8 @@
// Create quick reference variables for speed access to core prototypes.
var concat = ArrayProto.concat,
push = ArrayProto.push,
slice = ArrayProto.slice,
unshift = ArrayProto.unshift,
toString = ObjProto.toString,
hasOwnProperty = ObjProto.hasOwnProperty;
@@ -85,7 +85,7 @@
var i = -1;
var l = obj.length;
// We optimized for common use by only binding a context when it's passed
// We optimize for common use by only binding a context when it's passed.
if (context) {
iterator = function() { return fn.call(context, obj[i], i, obj); };
}
@@ -100,7 +100,7 @@
}
};
// A simple each, for dealing with non-sparse arrays and arguments objects
// A simple each, for dealing with non-sparse arrays and arguments objects.
var simpleEach = function(obj, iterator, index) {
index || (index = 0);
for (var l = obj.length; index < l; index++) {
@@ -114,7 +114,7 @@
'toLocaleString', 'toString', 'valueOf'
];
// IE < 9 makes properties, shadowing non-enumerable ones, non-enumerable too
// IE < 9 makes properties, shadowing non-enumerable ones, non-enumerable too.
var forShadowed = !{valueOf:0}.propertyIsEnumerable('valueOf') &&
function(obj, iterator) {
// Because IE < 9 can't set the `[[Enumerable]]` attribute of an existing
@@ -1021,8 +1021,9 @@
// A method to easily add functions to the OOP wrapper.
var addToWrapper = function(name, func) {
wrapper.prototype[name] = function() {
unshift.call(arguments, this._wrapped);
return result(func.apply(_, arguments), this._chain);
var args = [this._wrapped];
push.apply(args, arguments);
return result(func.apply(_, args), this._chain);
};
};