diff --git a/src/html.spec.ts b/src/html.spec.ts
index 983ed4ca..6d6507cb 100644
--- a/src/html.spec.ts
+++ b/src/html.spec.ts
@@ -1334,7 +1334,7 @@ describe('html', () => {
setX(20)
expect(document.body.innerHTML).toBe('Non Zero: 20')
- expect(document.body.children[0]).toEqual(n) // node should be kept
+ expect(document.body.children[0]).not.toEqual(n)
})
it('when nested', () => {
diff --git a/src/html.ts b/src/html.ts
index 344785d1..edc2af27 100644
--- a/src/html.ts
+++ b/src/html.ts
@@ -156,6 +156,10 @@ export class HtmlTemplate {
effectUnsub()
}
+ for (const item of this.#mountables) {
+ item.unmount()
+ }
+
for (const node of this.#nodes) {
if (
node instanceof ReactiveNode ||
diff --git a/src/utils/render-content.ts b/src/utils/render-content.ts
index 929a8bff..dbad670c 100644
--- a/src/utils/render-content.ts
+++ b/src/utils/render-content.ts
@@ -5,15 +5,15 @@ export const renderContent = (
content: unknown,
parentNode: HTMLElement | DocumentFragment,
cb?: (item: HtmlTemplate | Node) => void
-): Node[] => {
+): Array => {
if (content instanceof HtmlTemplate) {
content.render(parentNode)
cb?.(content)
- return content.nodes
+ return [content]
}
if (Array.isArray(content)) {
- let nodes: Node[] = []
+ let nodes: Array = []
for (const item of content) {
if (Array.isArray(item)) {