reverting an old change -- _.extend should absolutely copy undefined values.

This commit is contained in:
Jeremy Ashkenas
2012-01-23 15:48:35 -05:00
parent dd09162b8c
commit 99c17c4a0d
2 changed files with 2 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ $(document).ready(function() {
result = _.extend({x:'x'}, {a:'a', x:2}, {a:'b'});
ok(_.isEqual(result, {x:2, a:'b'}), 'extending from multiple source objects last property trumps');
result = _.extend({}, {a: void 0, b: null});
equals(_.keys(result).join(''), 'b', 'extend does not copy undefined values');
equals(_.keys(result).join(''), 'ab', 'extend does not copy undefined values');
});
test("objects: defaults", function() {

View File

@@ -635,7 +635,7 @@
_.extend = function(obj) {
each(slice.call(arguments, 1), function(source) {
for (var prop in source) {
if (source[prop] !== void 0) obj[prop] = source[prop];
obj[prop] = source[prop];
}
});
return obj;