Fixed incorrect property deletion.
h3rald h3rald@h3rald.com
Sat, 26 Sep 2020 15:21:00 +0200
2 files changed,
11 insertions(+),
2 deletions(-)
M
__tests__/vnode.js
→
__tests__/vnode.js
@@ -77,6 +77,16 @@ vnode1.redraw({ node, vnode });
expect(node.checked).toEqual(false); }); + it("should handle falsy props when redrawing", () => { + const vnode1 = h("test-element", { q: 1}); + const node = vnode1.render(); + expect(node.q).toEqual(1); + const vnode = h("test-element", { q: 0}); + vnode1.redraw({ node, vnode }); + expect(node.q).toEqual(0); + expect(vnode1.props.q).toEqual(0); + }); + it("should handle non-string props as properties and not create attributes", () => { const v = h("div", { test: true,
M
h3.js
→
h3.js
@@ -393,11 +393,10 @@ oldvnode.props[a] = newvnode.props[a];
newvnode.props[a] ? node.setAttribute(a, "") : node.removeAttribute(a); - } else if (!newvnode.props[a]) { + } else if ([null, undefined].includes(newvnode.props[a])) { delete oldvnode.props[a]; node.removeAttribute(a); } else if ( - newvnode.props[a] && newvnode.props[a] !== oldvnode.props[a] ) { oldvnode.props[a] = newvnode.props[a];