From 7837e9f0e3e3671bcc939506c795bce8b3065514 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Wed, 11 Dec 2019 21:45:39 -0500 Subject: Update popup preview frame message handlers --- ext/bg/js/settings/popup-preview-frame.js | 19 +++++++++---------- 1 file 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(); -- cgit v1.2.3