all repos — h3 @ 94248bd20d67a2d0c36b58e33996c2ee42319186

A tiny, extremely minimalist JavaScript microframework.

Additional test.
h3rald h3rald@h3rald.com
Wed, 29 Apr 2020 12:31:27 +0200
commit

94248bd20d67a2d0c36b58e33996c2ee42319186

parent

6dac2a189d2f0964d085dc160f885e135d378b2d

1 files changed, 18 insertions(+), 0 deletions(-)

jump to
M __tests__/vnode.js__tests__/vnode.js

@@ -152,6 +152,24 @@ oldvnode.redraw({ node: node, vnode: newvnode });

expect(node.childNodes[1].textContent).toEqual("c"); }); + it("should provide a redraw method that is able to figure out differences in existing children", () => { + const oldvnode = h3("div", [ + h3("span.test", "a"), + h3("span.test", "b"), + h3("span.test", "c"), + ]); + const newvnode = h3("div", [ + h3("span.test", "a"), + h3("span.test1", "b"), + h3("span.test", "c"), + ]); + const node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(node.childNodes[0].classList[0]).toEqual("test"); + expect(node.childNodes[1].classList[0]).toEqual("test1"); + expect(node.childNodes[2].classList[0]).toEqual("test"); + }); + it("should provide a redraw method that is able to update different attributes", () => { const oldvnode = h3("span", { title: "a", something: "b" }); const newvnode = h3("span", { title: "b", id: "bbb" });