deal with firefox object reference bug (fixes #49)
This commit is contained in:
parent
3319d0d3cd
commit
abdb5e68be
@ -35,19 +35,23 @@ window.yomichan = new class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
optionsSet(options) {
|
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.setBadgeBackgroundColor({color: '#d9534f'});
|
||||||
chrome.browserAction.setBadgeText({text: 'off'});
|
chrome.browserAction.setBadgeText({text: 'off'});
|
||||||
} else if (!dictConfigured(options)) {
|
} else if (!dictConfigured(this.options)) {
|
||||||
chrome.browserAction.setBadgeBackgroundColor({color: '#f0ad4e'});
|
chrome.browserAction.setBadgeBackgroundColor({color: '#f0ad4e'});
|
||||||
chrome.browserAction.setBadgeText({text: '!'});
|
chrome.browserAction.setBadgeText({text: '!'});
|
||||||
} else {
|
} else {
|
||||||
chrome.browserAction.setBadgeText({text: ''});
|
chrome.browserAction.setBadgeText({text: ''});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.anki.enable) {
|
if (this.options.anki.enable) {
|
||||||
this.anki = new AnkiConnect(this.options.anki.server);
|
this.anki = new AnkiConnect(this.options.anki.server);
|
||||||
} else {
|
} else {
|
||||||
this.anki = new AnkiNull();
|
this.anki = new AnkiNull();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Yomichan",
|
"name": "Yomichan",
|
||||||
"version": "1.1.14",
|
"version": "1.1.15",
|
||||||
|
|
||||||
"description": "Japanese dictionary with Anki integration",
|
"description": "Japanese dictionary with Anki integration",
|
||||||
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},
|
"icons": {"16": "mixed/img/icon16.png", "48": "mixed/img/icon48.png", "128": "mixed/img/icon128.png"},
|
||||||
|
Loading…
Reference in New Issue
Block a user