mirror of
https://github.com/zotero/zotero.git
synced 2026-10-05 02:43:38 +00:00
fx140: Add ChromeUtils.import() shim for plugins
We can decide if we want to keep this, but it's an easy change that seems useful for dev builds.
This commit is contained in:
parent
f0ac59f3dc
commit
9d6669eb1e
1 changed files with 16 additions and 0 deletions
|
|
@ -174,6 +174,22 @@ Zotero.Plugins = new function () {
|
|||
}
|
||||
);
|
||||
|
||||
// fx140: Shim ChromeUtils.import() in the plugin scope
|
||||
// TODO: Do we want this?
|
||||
scope.ChromeUtils = new Proxy(scope.ChromeUtils, {
|
||||
get(target, property, receiver) {
|
||||
if (property === 'import') {
|
||||
return function (uri) {
|
||||
let esmURI = uri.replace('.jsm', uri.includes('/zotero/') ? '.mjs' : '.sys.mjs');
|
||||
Zotero.warn('ChromeUtils.import() has been removed. Use importESModule():\n'
|
||||
+ ` ChromeUtils.importESModule("${esmURI}");`);
|
||||
return receiver.importESModule(esmURI);
|
||||
};
|
||||
}
|
||||
return Reflect.get(target, property, receiver);
|
||||
}
|
||||
});
|
||||
|
||||
scopes.set(addon.id, scope);
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue