Skip to content

Commit

Permalink
fix: add event listener add the end
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Nov 6, 2024
1 parent c03a7f0 commit e49640c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@htmx/htmx-toasts",
"version": "1.0.0",
"version": "1.0.1",
"description": "A simple toast notification system for htmx",
"repository": "zeiss/htmx-toasts",
"type": "module",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ export class HTMXToastsElement extends HTMLElement {
notifications = new Array<Notification>()

connectedCallback(): void {
window.addEventListener('htmx-toasts:notify', ((e: CustomEvent<Notify>) => this.addToast(e)) as EventListener)

if (!this.hasAttribute('role')) {
this.setAttribute('role', 'alert')
}
Expand All @@ -75,6 +73,8 @@ export class HTMXToastsElement extends HTMLElement {
styles.href = 'https://unpkg.com/[email protected]/dist/out.css'
styles.type = 'text/css'
this.shadowRoot?.appendChild(styles)

window.addEventListener('htmx-toasts:notify', ((e: CustomEvent<Notify>) => this.addToast(e)) as EventListener)
}

disconnectedCallback(): void {
Expand Down

0 comments on commit e49640c

Please sign in to comment.