mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Make _.defaults follow _.assign and only assign own properties of source.
Former-commit-id: 114dc47bbfa6db6a53a2fa03dd477fe86c3395cb
This commit is contained in:
@@ -651,6 +651,12 @@
|
||||
equal(lodash.contains([1, 2, 3], 1, 2), true, '_.contains should ignore `fromIndex`: ' + basename);
|
||||
equal(lodash.every([true, false, true]), false, '_.every: ' + basename);
|
||||
|
||||
function Foo() {}
|
||||
Foo.prototype = { 'a': 1 };
|
||||
|
||||
deepEqual(lodash.defaults({}, new Foo), Foo.prototype, '_.defaults should assign inherited `source` properties: ' + basename);
|
||||
deepEqual(lodash.extend({}, new Foo), Foo.prototype, '_.extend should assign inherited `source` properties: ' + basename);
|
||||
|
||||
actual = lodash.find(array, function(value) {
|
||||
return 'value' in value;
|
||||
});
|
||||
|
||||
14
test/test.js
14
test/test.js
@@ -421,6 +421,20 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('source property checks');
|
||||
|
||||
_.each(['assign', 'defaults'], function(methodName) {
|
||||
var func = _[methodName];
|
||||
|
||||
test('lodash.' + methodName + ' should not assign inherited `source` properties', function() {
|
||||
function Foo() {}
|
||||
Foo.prototype = { 'a': 1 };
|
||||
deepEqual(func({}, new Foo), {});
|
||||
});
|
||||
});
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
QUnit.module('strict mode checks');
|
||||
|
||||
_.each(['assign', 'bindAll', 'defaults'], function(methodName) {
|
||||
|
||||
Reference in New Issue
Block a user