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