isPlainObject is very weak
WebReflection opened this issue · comments
There are probably too many ||
in there so that the following produces the unexpected:
var
a = {value: {nodeType: {}}},
b = extend(true, {}, a)
;
b.value.nodeType === a.value.nodeType;
// true !!!
I think it should rather be
if (toString.call(obj) !== '[object Object]' && (
!obj || obj.nodeType || obj.setInterval)
) {
return false;
}
but I am not sure about all those checks and if this could cause regressions (hence the issue instead of a PR)
Cheers
The nodeType
line was added in the initial commit (7dd968b), but there's no tests for it, and I don't know why we'd want to bother not recursing into an object if somebody chose to pass an HTMLElement
. I'll remove it and release a new version.
thanks … also bear in mind the following should also be false:
var
a = {value: {setInterval: {}}},
b = extend(true, {}, a)
;
b.value.setInterval === a.value.setInterval;
// should be false
in case you want to add a test for it.
Cheers
Fixed in 65c58e9
Thanks!