Skip to content
This repository has been archived by the owner on Oct 26, 2024. It is now read-only.

Commit

Permalink
Fix error when target is null
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumebriday committed Aug 12, 2022
1 parent d16e5f5 commit ff52b6d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default class extends Controller {
}

async show (event: Event): Promise<void> {
// Temporally variable to prevent `event.currentTarget` to being null.
const element = event.currentTarget

let content: string = null

if (this.hasContentTarget) {
Expand All @@ -27,7 +30,7 @@ export default class extends Controller {

const fragment: DocumentFragment = document.createRange().createContextualFragment(content)
// @ts-ignore
event.currentTarget.appendChild(fragment)
element.appendChild(fragment)
}

hide (): void {
Expand Down

0 comments on commit ff52b6d

Please sign in to comment.