diff options
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/settings/popup-preview-frame.js | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/ext/bg/js/settings/popup-preview-frame.js b/ext/bg/js/settings/popup-preview-frame.js index 9f642681..860f128c 100644 --- a/ext/bg/js/settings/popup-preview-frame.js +++ b/ext/bg/js/settings/popup-preview-frame.js @@ -106,11 +106,10 @@ class SettingsPopupPreview { onMessage(e) { const {action, params} = e.data; - const handlers = SettingsPopupPreview.messageHandlers; - if (hasOwn(handlers, action)) { - const handler = handlers[action]; - handler(this, params); - } + const handler = SettingsPopupPreview._messageHandlers.get(action); + if (typeof handler !== 'function') { return; } + + handler(this, params); } onThemeDarkCheckboxChanged(node) { @@ -176,11 +175,11 @@ class SettingsPopupPreview { } } -SettingsPopupPreview.messageHandlers = { - setText: (self, {text}) => self.setText(text), - setCustomCss: (self, {css}) => self.setCustomCss(css), - setCustomOuterCss: (self, {css}) => self.setCustomOuterCss(css) -}; +SettingsPopupPreview._messageHandlers = new Map([ + ['setText', (self, {text}) => self.setText(text)], + ['setCustomCss', (self, {css}) => self.setCustomCss(css)], + ['setCustomOuterCss', (self, {css}) => self.setCustomOuterCss(css)] +]); SettingsPopupPreview.instance = SettingsPopupPreview.create(); |