Use getPrototypeOf to set inheritance when constructor is a function. [closes #2018]

This commit is contained in:
John-David Dalton
2016-02-18 21:52:19 -08:00
parent b83abfa9c1
commit e380062403

View File

@@ -5055,11 +5055,9 @@
* @returns {Object} Returns the initialized clone.
*/
function initCloneObject(object) {
if (isPrototype(object)) {
return {};
}
var Ctor = object.constructor;
return baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
return (isFunction(object.constructor) && !isPrototype(object))
? baseCreate(getPrototypeOf(object))
: {};
}
/**
@@ -5206,7 +5204,7 @@
*/
function isPrototype(value) {
var Ctor = value && value.constructor,
proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
proto = (isFunction(Ctor) && Ctor.prototype) || objectProto;
return value === proto;
}
@@ -10288,10 +10286,7 @@
objectToString.call(value) != objectTag || isHostObject(value)) {
return false;
}
var proto = objectProto;
if (typeof value.constructor == 'function') {
proto = getPrototypeOf(value);
}
var proto = getPrototypeOf(value);
if (proto === null) {
return true;
}
@@ -11919,7 +11914,7 @@
if (isArr) {
accumulator = isArray(object) ? new Ctor : [];
} else {
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
accumulator = isFunction(Ctor) ? baseCreate(getPrototypeOf(object)) : {};
}
} else {
accumulator = {};