Skip to content

Commit

Permalink
fix: use path property on detail
Browse files Browse the repository at this point in the history
  • Loading branch information
keithamus committed Oct 4, 2021
1 parent 1badbaa commit 57044fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 3 additions & 3 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'}))
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 57044fd

Please sign in to comment.