fix: fix unbind method issue. #470

pull/471/head
jaywcjlove 1 year ago
parent 7f389cebc4
commit bb1046c047

@ -285,7 +285,10 @@ function clearModifier(event) {
function unbind(keysInfo) { function unbind(keysInfo) {
// unbind(), unbind all keys // unbind(), unbind all keys
if (typeof keysInfo === 'undefined') { if (typeof keysInfo === 'undefined') {
Object.keys(_handlers).forEach(key => delete _handlers[key]); Object.keys(_handlers).forEach(key => {
Array.isArray(_handlers[key]) && _handlers[key].forEach(info => eachUnbind(info));
delete _handlers[key];
});
removeKeyEvent(null); removeKeyEvent(null);
} else if (Array.isArray(keysInfo)) { } else if (Array.isArray(keysInfo)) {
// support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}]) // support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}])

File diff suppressed because one or more lines are too long

@ -283,7 +283,10 @@ function clearModifier(event) {
function unbind(keysInfo) { function unbind(keysInfo) {
// unbind(), unbind all keys // unbind(), unbind all keys
if (typeof keysInfo === 'undefined') { if (typeof keysInfo === 'undefined') {
Object.keys(_handlers).forEach(key => delete _handlers[key]); Object.keys(_handlers).forEach(key => {
Array.isArray(_handlers[key]) && _handlers[key].forEach(info => eachUnbind(info));
delete _handlers[key];
});
removeKeyEvent(null); removeKeyEvent(null);
} else if (Array.isArray(keysInfo)) { } else if (Array.isArray(keysInfo)) {
// support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}]) // support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}])

5
dist/hotkeys.js vendored

@ -289,7 +289,10 @@
function unbind(keysInfo) { function unbind(keysInfo) {
// unbind(), unbind all keys // unbind(), unbind all keys
if (typeof keysInfo === 'undefined') { if (typeof keysInfo === 'undefined') {
Object.keys(_handlers).forEach(key => delete _handlers[key]); Object.keys(_handlers).forEach(key => {
Array.isArray(_handlers[key]) && _handlers[key].forEach(info => eachUnbind(info));
delete _handlers[key];
});
removeKeyEvent(null); removeKeyEvent(null);
} else if (Array.isArray(keysInfo)) { } else if (Array.isArray(keysInfo)) {
// support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}]) // support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}])

File diff suppressed because one or more lines are too long

@ -123,7 +123,10 @@ function clearModifier(event) {
function unbind(keysInfo, ...args) { function unbind(keysInfo, ...args) {
// unbind(), unbind all keys // unbind(), unbind all keys
if (typeof keysInfo === 'undefined') { if (typeof keysInfo === 'undefined') {
Object.keys(_handlers).forEach((key) => delete _handlers[key]); Object.keys(_handlers).forEach((key) => {
Array.isArray(_handlers[key]) && _handlers[key].forEach((info) => eachUnbind(info));
delete _handlers[key];
});
removeKeyEvent(null); removeKeyEvent(null);
} else if (Array.isArray(keysInfo)) { } else if (Array.isArray(keysInfo)) {
// support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}]) // support like : unbind([{key: 'ctrl+a', scope: 's1'}, {key: 'ctrl-a', scope: 's2', splitKey: '-'}])

Loading…
Cancel
Save