Skip to content

Commit

Permalink
clean up shadow root
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBLT committed Jan 11, 2024
1 parent 6605d8b commit 2cb7fd7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/@hec.js/ui/lib/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function component(name, props, fn) {

this.dispatchEvent(new CustomEvent('::load', { bubbles: true }));

const shadow = this.attachShadow({ mode: 'open' }),
const shadow = this.shadowRoot ?? this.attachShadow({ mode: 'open' }),
node = fn(this.#signals, this);

/** @param { Node } node */
Expand Down Expand Up @@ -112,6 +112,12 @@ export function component(name, props, fn) {
delete this.#aborts[k];
}

if (this.shadowRoot) {
while (this.shadowRoot.childNodes) {
this.shadowRoot.lastChild.remove();
}
}

this.dispatchEvent(new CustomEvent('::unmount'));
}

Expand Down

0 comments on commit 2cb7fd7

Please sign in to comment.