Update popup preview frame message handlers

This commit is contained in:
toasted-nutbread 2019-12-11 21:45:39 -05:00
parent 5588643988
commit 7837e9f0e3

View File

@ -106,12 +106,11 @@ class SettingsPopupPreview {
onMessage(e) { onMessage(e) {
const {action, params} = e.data; const {action, params} = e.data;
const handlers = SettingsPopupPreview.messageHandlers; const handler = SettingsPopupPreview._messageHandlers.get(action);
if (hasOwn(handlers, action)) { if (typeof handler !== 'function') { return; }
const handler = handlers[action];
handler(this, params); handler(this, params);
} }
}
onThemeDarkCheckboxChanged(node) { onThemeDarkCheckboxChanged(node) {
document.documentElement.classList.toggle('dark', node.checked); document.documentElement.classList.toggle('dark', node.checked);
@ -176,11 +175,11 @@ class SettingsPopupPreview {
} }
} }
SettingsPopupPreview.messageHandlers = { SettingsPopupPreview._messageHandlers = new Map([
setText: (self, {text}) => self.setText(text), ['setText', (self, {text}) => self.setText(text)],
setCustomCss: (self, {css}) => self.setCustomCss(css), ['setCustomCss', (self, {css}) => self.setCustomCss(css)],
setCustomOuterCss: (self, {css}) => self.setCustomOuterCss(css) ['setCustomOuterCss', (self, {css}) => self.setCustomOuterCss(css)]
}; ]);
SettingsPopupPreview.instance = SettingsPopupPreview.create(); SettingsPopupPreview.instance = SettingsPopupPreview.create();