*/
createIllegalConstructor,
} = (() => {
- // ☡ Because these functions are used to initialize module constants,
- // they can’t depend on imports from elsewhere.
+ const { prototype: functionPrototype } = Function;
const {
bind: functionBind,
call: functionCall,
- } = Function.prototype;
+ } = functionPrototype;
const callBind = Reflect.apply(functionBind, functionCall, [
functionBind,
]);
create: objectCreate,
defineProperty: defineOwnProperty,
defineProperties: defineOwnProperties,
+ hasOwn: hasOwnProperty,
getPrototypeOf: getPrototype,
setPrototypeOf: setPrototype,
} = Object;
} else {
// A base function was provided; apply it.
const { length, name, prototype } = base;
- setPrototype($, getPrototype(base));
+ if (getPrototype($) === functionPrototype) {
+ setPrototype($, getPrototype(base));
+ } else {
+ /* do nothing */
+ }
return applyProperties($, {
length: +length + lengthDelta,
name,
} else {
// Properties were provided; apply them.
const { length, name, prototype } = override;
- if (!isConstructor($) || prototype === undefined) {
- // The provided function is not a constructor or no prototype
- // value was provided.
+ if (
+ !isConstructor($) || !hasOwnProperty($, "prototype") ||
+ prototype === undefined
+ ) {
+ // The provided function is not a constructor, has no
+ // `.prototype`, or no prototype value was provided.
//
// Do not modify the prototype property of the provided
// function.