mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 20:46:39 +02:00
Get rid of eval.
This commit is contained in:
parent
32f9ea7447
commit
14a4d1cdc2
10 changed files with 96 additions and 50 deletions
|
@ -44,5 +44,31 @@
|
|||
};
|
||||
Object.seal(scope.message);
|
||||
|
||||
scope.getWrapped = function getWrapped(obj){
|
||||
return obj && (obj.wrappedJSObject || obj);
|
||||
};
|
||||
|
||||
scope.exportFunctionWithName = function exportFunctionWithName(func, context, name){
|
||||
const exportedTry = exportFunction(func, context);
|
||||
if (exportedTry.name === name){
|
||||
return exportedTry;
|
||||
}
|
||||
else {
|
||||
const wrappedContext = scope.getWrapped(context);
|
||||
const options = {
|
||||
defineAs: name
|
||||
};
|
||||
const oldDescriptor = Object.getOwnPropertyDescriptor(wrappedContext, name);
|
||||
const exported = exportFunction(func, context, options);
|
||||
if (oldDescriptor){
|
||||
Object.defineProperty(wrappedContext, name, oldDescriptor);
|
||||
}
|
||||
else {
|
||||
delete wrappedContext[name];
|
||||
}
|
||||
return exported;
|
||||
}
|
||||
};
|
||||
|
||||
Object.seal(scope);
|
||||
}());
|
Loading…
Add table
Add a link
Reference in a new issue