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) {
const {action, params} = e.data;
const handlers = SettingsPopupPreview.messageHandlers;
if (hasOwn(handlers, action)) {
const handler = handlers[action];
const handler = SettingsPopupPreview._messageHandlers.get(action);
if (typeof handler !== 'function') { return; }
handler(this, params);
}
}
onThemeDarkCheckboxChanged(node) {
document.documentElement.classList.toggle('dark', node.checked);
@ -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();