Skip to content

Commit

Permalink
Reattach state when child elements change
Browse files Browse the repository at this point in the history
  • Loading branch information
camertron committed Mar 5, 2024
1 parent dcbc8f3 commit eae8e75
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/auto-complete-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ export class AutoCompleteElement extends HTMLElement {
connectedCallback(): void {
if (!this.isConnected) return
this.#reattachState()

new MutationObserver(() => {
if (!state.get(this)) {
this.#reattachState()
}
}).observe(this, {subtree: true, childList: true})
}

disconnectedCallback(): void {
Expand Down

0 comments on commit eae8e75

Please sign in to comment.