@github/hotkey
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -217,3 +217,3 @@ function _classCallCheck(instance, Constructor) { | ||
document.addEventListener('keydown', function (event) { | ||
function keyDownHandler(event) { | ||
if (event.target instanceof Node && isFormField(event.target)) return; | ||
@@ -243,4 +243,9 @@ | ||
} | ||
}); | ||
} | ||
function install(element, hotkey$$1) { | ||
// Install the keydown handler if this is the first install | ||
if (Object.keys(hotkeyRadixTrie.children).length === 0) { | ||
document.addEventListener('keydown', keyDownHandler); | ||
} | ||
var hotkeys = expandHotkeyToEdges(hotkey$$1 || element.getAttribute('data-hotkey') || ''); | ||
@@ -280,4 +285,8 @@ var leaves = hotkeys.map(function (hotkey$$1) { | ||
} | ||
if (Object.keys(hotkeyRadixTrie.children).length === 0) { | ||
document.removeEventListener('keydown', keyDownHandler); | ||
} | ||
} | ||
export { RadixTrie, Leaf, hotkey as eventToHotkeyString, install, uninstall }; |
@@ -223,3 +223,3 @@ (function (global, factory) { | ||
document.addEventListener('keydown', function (event) { | ||
function keyDownHandler(event) { | ||
if (event.target instanceof Node && isFormField(event.target)) return; | ||
@@ -249,4 +249,9 @@ | ||
} | ||
}); | ||
} | ||
function install(element, hotkey$$1) { | ||
// Install the keydown handler if this is the first install | ||
if (Object.keys(hotkeyRadixTrie.children).length === 0) { | ||
document.addEventListener('keydown', keyDownHandler); | ||
} | ||
var hotkeys = expandHotkeyToEdges(hotkey$$1 || element.getAttribute('data-hotkey') || ''); | ||
@@ -286,2 +291,6 @@ var leaves = hotkeys.map(function (hotkey$$1) { | ||
} | ||
if (Object.keys(hotkeyRadixTrie.children).length === 0) { | ||
document.removeEventListener('keydown', keyDownHandler); | ||
} | ||
} | ||
@@ -288,0 +297,0 @@ |
{ | ||
"name": "@github/hotkey", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.umd.js", |
@@ -64,2 +64,3 @@ # Hotkey Behavior | ||
// Install all the hotkeys on the page | ||
for (const el of document.querySelectorAll('[data-hotkey]')) { | ||
@@ -66,0 +67,0 @@ install(el) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22233
495
98