Skip to content

Commit dd4f764

Browse files
committed
Improve proxy-apply utility scriptlet
1 parent 6623889 commit dd4f764

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/js/resources/proxy-apply.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ export function proxyApplyFn(
8585
: new proxyApplyFn.ApplyContext(...args);
8686
}
8787
};
88+
proxyApplyFn.isCtor = new Map();
89+
}
90+
if ( proxyApplyFn.isCtor.has(target) === false ) {
91+
proxyApplyFn.isCtor.set(target, fn.prototype?.constructor === fn);
8892
}
8993
const fnStr = fn.toString();
9094
const toString = (function toString() { return fnStr; }).bind(null);
@@ -97,7 +101,7 @@ export function proxyApplyFn(
97101
return Reflect.get(target, prop);
98102
},
99103
};
100-
if ( fn.prototype?.constructor === fn ) {
104+
if ( proxyApplyFn.isCtor.get(target) ) {
101105
proxyDetails.construct = function(target, args) {
102106
return handler(proxyApplyFn.CtorContext.factory(target, args));
103107
};

0 commit comments

Comments
 (0)