mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
Improve proxy-apply utility scriptlet
This commit is contained in:
parent
6623889920
commit
dd4f764920
1 changed files with 5 additions and 1 deletions
|
|
@ -85,6 +85,10 @@ export function proxyApplyFn(
|
|||
: new proxyApplyFn.ApplyContext(...args);
|
||||
}
|
||||
};
|
||||
proxyApplyFn.isCtor = new Map();
|
||||
}
|
||||
if ( proxyApplyFn.isCtor.has(target) === false ) {
|
||||
proxyApplyFn.isCtor.set(target, fn.prototype?.constructor === fn);
|
||||
}
|
||||
const fnStr = fn.toString();
|
||||
const toString = (function toString() { return fnStr; }).bind(null);
|
||||
|
|
@ -97,7 +101,7 @@ export function proxyApplyFn(
|
|||
return Reflect.get(target, prop);
|
||||
},
|
||||
};
|
||||
if ( fn.prototype?.constructor === fn ) {
|
||||
if ( proxyApplyFn.isCtor.get(target) ) {
|
||||
proxyDetails.construct = function(target, args) {
|
||||
return handler(proxyApplyFn.CtorContext.factory(target, args));
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue