diff --git a/src/sandbox/common.ts b/src/sandbox/common.ts index af34633..e05700c 100644 --- a/src/sandbox/common.ts +++ b/src/sandbox/common.ts @@ -28,6 +28,8 @@ export function getTargetValue(target: any, value: any): any { const boundValue = value.bind(target); // some callable function has custom fields, we need to copy the enumerable props to boundValue. such as moment function. Object.keys(value).forEach(key => (boundValue[key] = value[key])); + // copy prototype, for performance reason, we use in operator to check rather than hasOwnProperty + if ('prototype' in value) boundValue.prototype = value.prototype; Object.defineProperty(value, boundValueSymbol, { enumerable: false, value: boundValue }); return boundValue; }