diff --git a/src/utils.ts b/src/utils.ts index 0ef6ffa..13978c0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -13,8 +13,8 @@ export function isFormField(element: Node): boolean { ) } -export function fireDeterminedAction(el: HTMLElement, detail: string[]): void { - const delegateEvent = new CustomEvent('hotkey-fire', {cancelable: true, detail}) +export function fireDeterminedAction(el: HTMLElement, path: string[]): void { + const delegateEvent = new CustomEvent('hotkey-fire', {cancelable: true, detail: {path}}) const cancelled = !el.dispatchEvent(delegateEvent) if (cancelled) return if (isFormField(el)) { diff --git a/test/test.js b/test/test.js index 01f3635..b8c0089 100644 --- a/test/test.js +++ b/test/test.js @@ -100,7 +100,7 @@ describe('hotkey', function () { let fired = false document.querySelector('#button1').addEventListener('hotkey-fire', event => { fired = true - assert.deepEqual(event.detail, ['B']) + assert.deepEqual(event.detail.path, ['B']) assert.equal(event.cancelable, true) }) document.dispatchEvent(new KeyboardEvent('keydown', {shiftKey: true, code: 'KeyB', key: 'B'})) @@ -179,7 +179,7 @@ describe('hotkey', function () { let fired = false document.querySelector('#button1').addEventListener('hotkey-fire', event => { fired = true - assert.deepEqual(event.detail, ['Meta+b']) + assert.deepEqual(event.detail.path, ['Meta+b']) assert.equal(event.cancelable, true) }) document @@ -262,7 +262,7 @@ describe('hotkey', function () { let fired = false document.querySelector('#link3').addEventListener('hotkey-fire', event => { fired = true - assert.deepEqual(event.detail, ['d', 'e', 'f']) + assert.deepEqual(event.detail.path, ['d', 'e', 'f']) assert.equal(event.cancelable, true) }) await keySequence('d e f')