aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2017-04-29 12:35:43 -0700
committerAlex Yatskov <alex@foosoft.net>2017-04-29 12:35:43 -0700
commit1cdf496824709b4e4579d700c333e832d790925e (patch)
treefd50754905ee3319e3fa9738932bab23daa741c6 /ext/bg/js
parenta209228c311a13328ecdda4056a9302885639195 (diff)
parentabdb5e68beca1e9105b998defcc37015bf735119 (diff)
Merge branch 'master' into firefox-amo
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/yomichan.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index 172bb1d3..7be67d01 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -35,19 +35,23 @@ window.yomichan = new class {
}
optionsSet(options) {
- this.options = options;
+ // In Firefox, setting options from the options UI somehow carries references
+ // to the DOM across to the background page, causing the options object to
+ // become a "DeadObject" after the options page is closed. The workaround used
+ // here is to create a deep copy of the options object.
+ this.options = JSON.parse(JSON.stringify(options));
- if (!options.general.enable) {
+ if (!this.options.general.enable) {
chrome.browserAction.setBadgeBackgroundColor({color: '#d9534f'});
chrome.browserAction.setBadgeText({text: 'off'});
- } else if (!dictConfigured(options)) {
+ } else if (!dictConfigured(this.options)) {
chrome.browserAction.setBadgeBackgroundColor({color: '#f0ad4e'});
chrome.browserAction.setBadgeText({text: '!'});
} else {
chrome.browserAction.setBadgeText({text: ''});
}
- if (options.anki.enable) {
+ if (this.options.anki.enable) {
this.anki = new AnkiConnect(this.options.anki.server);
} else {
this.anki = new AnkiNull();