Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove handlers (rather than setting to {}) in eachUnbind #345

Merged
merged 2 commits into from
Apr 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions dist/hotkeys.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
Expand Down Expand Up @@ -308,15 +308,10 @@ var eachUnbind = function eachUnbind(_ref) {

if (!scope) scope = getScope();
var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;

if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}

return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});
});
}; // 对监听对应快捷键的回调函数进行处理
Expand Down
4 changes: 2 additions & 2 deletions dist/hotkeys.common.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions dist/hotkeys.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
Expand Down Expand Up @@ -306,15 +306,10 @@ var eachUnbind = function eachUnbind(_ref) {

if (!scope) scope = getScope();
var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;

if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}

return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});
});
}; // 对监听对应快捷键的回调函数进行处理
Expand Down Expand Up @@ -569,4 +564,4 @@ if (typeof window !== 'undefined') {
window.hotkeys = hotkeys;
}

export default hotkeys;
export { hotkeys as default };
15 changes: 5 additions & 10 deletions dist/hotkeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* hotkeys-js v3.8.7
* A simple micro-library for defining and dispatching keyboard shortcuts. It has no dependencies.
*
* Copyright (c) 2021 kenny wong <wowohoo@qq.com>
* Copyright (c) 2022 kenny wong <wowohoo@qq.com>
* http://jaywcjlove.github.io/hotkeys
*
* Licensed under the MIT license.
Expand All @@ -12,7 +12,7 @@
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.hotkeys = factory());
}(this, (function () { 'use strict';
})(this, (function () { 'use strict';

var isff = typeof navigator !== 'undefined' ? navigator.userAgent.toLowerCase().indexOf('firefox') > 0 : false; // 绑定事件

Expand Down Expand Up @@ -312,15 +312,10 @@

if (!scope) scope = getScope();
var mods = len > 1 ? getMods(_modifier, unbindKeys) : [];
_handlers[keyCode] = _handlers[keyCode].map(function (record) {
_handlers[keyCode] = _handlers[keyCode].filter(function (record) {
// 通过函数判断,是否解除绑定,函数相等直接返回
var isMatchingMethod = method ? record.method === method : true;

if (isMatchingMethod && record.scope === scope && compareArray(record.mods, mods)) {
return {};
}

return record;
return !(isMatchingMethod && record.scope === scope && compareArray(record.mods, mods));
});
});
}; // 对监听对应快捷键的回调函数进行处理
Expand Down Expand Up @@ -577,4 +572,4 @@

return hotkeys;

})));
}));
Loading