summaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-11 21:43:59 -0500
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-12-13 23:11:56 -0500
commit5588643988e3154ecd6987bcf4794881e33a4ca2 (patch)
tree436bd7baa752d195d59d2f2a17a972e5b41751ce /ext/fg/js
parenta2263e57292b7b6822c37c951b40b355a277fecd (diff)
Update float message handlers
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/float.js21
1 files changed, 10 insertions, 11 deletions
diff --git a/ext/fg/js/float.js b/ext/fg/js/float.js
index ae54be00..f25dfd73 100644
--- a/ext/fg/js/float.js
+++ b/ext/fg/js/float.js
@@ -48,11 +48,10 @@ class DisplayFloat extends Display {
onMessage(e) {
const {action, params} = e.data;
- const handlers = DisplayFloat.messageHandlers;
- if (hasOwn(handlers, action)) {
- const handler = handlers[action];
- handler(this, params);
- }
+ const handler = DisplayFloat._messageHandlers.get(action);
+ if (typeof handler !== 'function') { return; }
+
+ handler(this, params);
}
onKeyDown(e) {
@@ -107,11 +106,11 @@ DisplayFloat.onKeyDownHandlers = {
}
};
-DisplayFloat.messageHandlers = {
- setContent: (self, {type, details}) => self.setContent(type, details),
- clearAutoPlayTimer: (self) => self.clearAutoPlayTimer(),
- setCustomCss: (self, {css}) => self.setCustomCss(css),
- initialize: (self, {options, popupInfo, url, childrenSupported}) => self.initialize(options, popupInfo, url, childrenSupported)
-};
+DisplayFloat._messageHandlers = new Map([
+ ['setContent', (self, {type, details}) => self.setContent(type, details)],
+ ['clearAutoPlayTimer', (self) => self.clearAutoPlayTimer()],
+ ['setCustomCss', (self, {css}) => self.setCustomCss(css)],
+ ['initialize', (self, {options, popupInfo, url, childrenSupported}) => self.initialize(options, popupInfo, url, childrenSupported)]
+]);
window.yomichan_display = new DisplayFloat();