summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/bg/js/util.js22
-rw-r--r--ext/mixed/js/core.js5
2 files changed, 5 insertions, 22 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js
index fa31b0d8..a0f31653 100644
--- a/ext/bg/js/util.js
+++ b/ext/bg/js/util.js
@@ -15,33 +15,11 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-function utilFunctionIsolate(func) {
- return function isolatedFunction(...args) {
- try {
- args = args.map((v) => clone(v));
- return func.call(this, ...args);
- } catch (e) {
- try {
- String(func);
- } catch (e2) {
- // Dead object
- return;
- }
- throw e;
- }
- };
-}
-
function utilBackgroundIsolate(data) {
const backgroundPage = chrome.extension.getBackgroundPage();
return backgroundPage.clone(data);
}
-function utilBackgroundFunctionIsolate(func) {
- const backgroundPage = chrome.extension.getBackgroundPage();
- return backgroundPage.utilFunctionIsolate(func);
-}
-
function utilBackend() {
const backend = chrome.extension.getBackgroundPage().yomichanBackend;
if (!backend.isPrepared()) {
diff --git a/ext/mixed/js/core.js b/ext/mixed/js/core.js
index fec26a0e..7cdd62d8 100644
--- a/ext/mixed/js/core.js
+++ b/ext/mixed/js/core.js
@@ -192,6 +192,11 @@ const clone = (() => {
return clone;
})();
+// Expose clone function on the global object, since util.js's utilBackgroundIsolate needs access to it.
+if (typeof window === 'object' && window !== null) {
+ window.clone = clone;
+}
+
/*
* Async utilities