Skip to content

Commit

Permalink
Merge pull request #118 from github/reattach_on_mutate
Browse files Browse the repository at this point in the history
Reattach state when child elements change
  • Loading branch information
keithamus authored Mar 6, 2024
2 parents dcbc8f3 + eae8e75 commit 48c2d2c
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 48c2d2c

Please sign in to comment.