1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00

Use Reflect.construct(t) rather than new t()

Using `new` seemed to work but it's maybe
semantically better to use `Reflect.construct`.
This commit is contained in:
Raymond Hill 2019-07-11 09:45:53 -04:00
parent 7183ce8f42
commit c499ce82a9
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -605,9 +605,9 @@ const uBOSafe = new Map(); // jshint ignore: line
apply: function(target, thisArg, args) { apply: function(target, thisArg, args) {
if ( isGoodConfig(target, args[1]) === false ) { if ( isGoodConfig(target, args[1]) === false ) {
log(args[1]); log(args[1]);
return target.apply(thisArg, args.slice(0, 1)); return Reflect.apply(target, thisArg, args.slice(0, 1));
} }
return target.apply(thisArg, args); return Reflect.apply(target, thisArg, args);
}, },
}); });
window[rtcName] = window[rtcName] =
@ -615,9 +615,9 @@ const uBOSafe = new Map(); // jshint ignore: line
construct: function(target, args) { construct: function(target, args) {
if ( isGoodConfig(target, args[0]) === false ) { if ( isGoodConfig(target, args[0]) === false ) {
log(args[0]); log(args[0]);
return new target(); return Reflect.construct(target);
} }
return new target(...args); return Reflect.construct(target, args);
} }
}); });
})(); })();