From eae8e75df8baccc23529a204d2fe7314dff55239 Mon Sep 17 00:00:00 2001 From: Cameron Dutro Date: Tue, 5 Mar 2024 15:00:03 -0800 Subject: [PATCH] Reattach state when child elements change --- src/auto-complete-element.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/auto-complete-element.ts b/src/auto-complete-element.ts index 76a742e..9a90c10 100644 --- a/src/auto-complete-element.ts +++ b/src/auto-complete-element.ts @@ -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 {