Skip to content

Commit 7b69aea

Browse files
committed
fix: update properly html block internal state
1 parent 26402f5 commit 7b69aea

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/html.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class VHtml {
6161
// remove current content
6262
this.remove();
6363
this.content = content;
64+
this.html = other.html;
6465
}
6566
}
6667

tests/html.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createBlock, html, mount, patch, text } from "../src";
1+
import { createBlock, html, mount, multi, patch, text } from "../src";
22
import { makeTestFixture } from "./helpers";
33

44
//------------------------------------------------------------------------------
@@ -45,4 +45,16 @@ describe("html block", () => {
4545
patch(tree, html(`<tr><td>potato</td></tr>`));
4646
expect(fixture.innerHTML).toBe("<tr><td>potato</td></tr>");
4747
});
48+
49+
test("html vnode can be used in a multi, and updated", () => {
50+
const tree = multi([html("<p>a</p>"), html("<p>b</p>")]);
51+
mount(tree, fixture);
52+
expect(fixture.innerHTML).toBe("<p>a</p><p>b</p>");
53+
54+
patch(tree, multi([html("<p>b</p>"), html("<p>a</p>")]));
55+
expect(fixture.innerHTML).toBe("<p>b</p><p>a</p>");
56+
57+
patch(tree, multi([html("<p>a</p>"), html("<p>b</p>")]));
58+
expect(fixture.innerHTML).toBe("<p>a</p><p>b</p>");
59+
});
4860
});

0 commit comments

Comments
 (0)