Browse Source

feat(keyboard-shortcuts): fix removing shortcuts (#2749)

master
Saúl Ibarra Corretgé 7 years ago
parent
commit
95e00405b6
1 changed files with 9 additions and 9 deletions
  1. 9
    9
      modules/keyboardshortcut/keyboardshortcut.js

+ 9
- 9
modules/keyboardshortcut/keyboardshortcut.js View File

15
 
15
 
16
 /**
16
 /**
17
  * Map of shortcuts. When a shortcut is registered it enters the mapping.
17
  * Map of shortcuts. When a shortcut is registered it enters the mapping.
18
- * @type {{}}
18
+ * @type {Map}
19
  */
19
  */
20
-const _shortcuts = {};
20
+const _shortcuts = new Map();
21
 
21
 
22
 /**
22
 /**
23
  * Map of registered keyboard keys and translation keys describing the
23
  * Map of registered keyboard keys and translation keys describing the
49
             if (!($(':focus').is('input[type=text]')
49
             if (!($(':focus').is('input[type=text]')
50
                 || $(':focus').is('input[type=password]')
50
                 || $(':focus').is('input[type=password]')
51
                 || $(':focus').is('textarea'))) {
51
                 || $(':focus').is('textarea'))) {
52
-                if (_shortcuts.hasOwnProperty(key)) {
53
-                    _shortcuts[key].function(e);
52
+                if (_shortcuts.has(key)) {
53
+                    _shortcuts.get(key).function(e);
54
                 } else if (!isNaN(num) && num >= 0 && num <= 9) {
54
                 } else if (!isNaN(num) && num >= 0 && num <= 9) {
55
                     APP.UI.clickOnVideo(num);
55
                     APP.UI.clickOnVideo(num);
56
                 }
56
                 }
117
             shortcutAttr,
117
             shortcutAttr,
118
             exec,
118
             exec,
119
             helpDescription) {
119
             helpDescription) {
120
-        _shortcuts[shortcutChar] = {
120
+        _shortcuts.set(shortcutChar, {
121
             character: shortcutChar,
121
             character: shortcutChar,
122
-            shortcutAttr,
123
-            function: exec
124
-        };
122
+            function: exec,
123
+            shortcutAttr
124
+        });
125
 
125
 
126
         if (helpDescription) {
126
         if (helpDescription) {
127
             this._addShortcutToHelp(shortcutChar, helpDescription);
127
             this._addShortcutToHelp(shortcutChar, helpDescription);
135
      * no longer be usable
135
      * no longer be usable
136
      */
136
      */
137
     unregisterShortcut(shortcutChar) {
137
     unregisterShortcut(shortcutChar) {
138
-        _shortcuts.remove(shortcutChar);
138
+        _shortcuts.delete(shortcutChar);
139
         _shortcutsHelp.delete(shortcutChar);
139
         _shortcutsHelp.delete(shortcutChar);
140
     },
140
     },
141
 
141
 

Loading…
Cancel
Save