Skip to content

Commit 59351a4

Browse files
committed
Fix the issue #4
1 parent a7a23af commit 59351a4

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ function _setDeep(obj, keyElems, depth, valueCreator) {
189189
if (value === undefined) {
190190
return;
191191
}
192-
if (isObject(value)) { // value is always an empty object.
193-
if (isObject(obj[key])) {
192+
if (isPlainObject(value)) { // value is always an empty object.
193+
if (isPlainObject(obj[key])) {
194194
return;
195195
}
196196
}

test/copy-props-proc.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,19 @@ describe('Processing', function() {
166166
var dst = { a: { b: { c: 1 } } };
167167
expect(copyProps(src, dst)).to.deep.equal({ a: { b: { c: 1 } } });
168168
});
169+
170+
it('Should copy normally when src prop is not a plain object but an ' +
171+
'object', function() {
172+
function O(v) {
173+
this.a = { b: { c: v } };
174+
}
175+
var o1 = new O(123);
176+
var o2 = new O(456);
177+
var p1 = { o: o1 };
178+
var p2 = { o: o2 };
179+
copyProps(p1, p2);
180+
expect(p2.o).to.equal(o1);
181+
});
169182
});
170183

171184
describe('About fromto special cases', function() {

0 commit comments

Comments
 (0)