Merge pull request #1505 from nskazki/detach-event-listeners-on-destroy

Detach event listeners on destroy
This commit is contained in:
Sam Potts
2020-01-13 16:31:17 +00:00
committed by GitHub

12
src/js/controls.js vendored
View File

@ -399,7 +399,8 @@ const controls = {
// https://bugzilla.mozilla.org/show_bug.cgi?id=1220143 // https://bugzilla.mozilla.org/show_bug.cgi?id=1220143
bindMenuItemShortcuts(menuItem, type) { bindMenuItemShortcuts(menuItem, type) {
// Navigate through menus via arrow keys and space // Navigate through menus via arrow keys and space
on( on.call(
this,
menuItem, menuItem,
'keydown keyup', 'keydown keyup',
event => { event => {
@ -449,7 +450,7 @@ const controls = {
// Enter will fire a `click` event but we still need to manage focus // Enter will fire a `click` event but we still need to manage focus
// So we bind to keyup which fires after and set focus here // So we bind to keyup which fires after and set focus here
on(menuItem, 'keyup', event => { on.call(this, menuItem, 'keyup', event => {
if (event.which !== 13) { if (event.which !== 13) {
return; return;
} }
@ -1460,7 +1461,7 @@ const controls = {
bindMenuItemShortcuts.call(this, menuItem, type); bindMenuItemShortcuts.call(this, menuItem, type);
// Show menu on click // Show menu on click
on(menuItem, 'click', () => { on.call(this, menuItem, 'click', () => {
showMenuPanel.call(this, type, false); showMenuPanel.call(this, type, false);
}); });
@ -1512,7 +1513,8 @@ const controls = {
); );
// Go back via keyboard // Go back via keyboard
on( on.call(
this,
pane, pane,
'keydown', 'keydown',
event => { event => {
@ -1532,7 +1534,7 @@ const controls = {
); );
// Go back via button click // Go back via button click
on(backButton, 'click', () => { on.call(this, backButton, 'click', () => {
showMenuPanel.call(this, 'home', false); showMenuPanel.call(this, 'home', false);
}); });