all repos — h3 @ 62617cad58065e00ed88b1f7e223a25b2ee418b4

A tiny, extremely minimalist JavaScript microframework.

Updated tests.
h3rald h3rald@h3rald.com
Thu, 16 Apr 2020 18:43:07 +0200
commit

62617cad58065e00ed88b1f7e223a25b2ee418b4

parent

a8a2c43873ff6c28c7f299eab33de5da40716384

2 files changed, 96 insertions(+), 16 deletions(-)

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

@@ -111,24 +111,26 @@ type: "div",

children: [ { attributes: {}, - children: {}, + children: [], classList: [], data: {}, eventListeners: {}, id: undefined, key: undefined, - style: "#text", + style: undefined, + type: "#text", value: "a", }, { attributes: {}, - children: {}, + children: [], classList: [], data: {}, eventListeners: {}, id: undefined, key: undefined, - style: "#text", + style: undefined, + type: "#text", value: "b", }, ],

@@ -148,8 +150,39 @@ expect(

h3("div.test", { title: "Test...", id: "test" }, ["a", "b"]) ).toEqual({ type: "div", - children: ["a", "b"], - attributes: { title: "Test...", id: "test" }, + children: [ + { + attributes: {}, + children: [], + classList: [], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + type: "#text", + value: "a", + }, + { + attributes: {}, + children: [], + classList: [], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + type: "#text", + value: "b", + }, + ], + data: {}, + eventListeners: {}, + id: "test", + key: undefined, + style: undefined, + value: undefined, + attributes: { title: "Test..." }, classList: ["test"], }); });

@@ -158,20 +191,67 @@ it("should support the creation of virtual node elements with attributes", () => {

expect(h3("input", { type: "text", value: "AAA" })).toEqual({ type: "input", children: [], - attributes: { type: "text", value: "AAA" }, + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + value: "AAA", + attributes: { type: "text" }, classList: [], }); }); it("should support the creation of virtual node elements with element children and classes", () => { - expect(h3("div.test", ["a", h3("span", ["test"])])).toEqual({ + expect(h3("div.test", ["a", h3("span", ["test1"])])).toEqual({ + attributes: {}, type: "div", children: [ - "a", - { type: "span", children: ["test"], attributes: {}, classList: [] }, + { + attributes: {}, + children: [], + classList: [], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + type: "#text", + value: "a", + }, + { + type: "span", + children: [ + { + attributes: {}, + children: [], + classList: [], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + type: "#text", + value: "test1", + }, + ], + attributes: {}, + classList: [], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + value: undefined, + }, ], - attributes: {}, classList: ["test"], + data: {}, + eventListeners: {}, + id: undefined, + key: undefined, + style: undefined, + value: undefined, }); });
M h3.jsh3.js

@@ -96,13 +96,13 @@ delete this.attributes.style;

} constructor(...args) { - this.type = null; + this.type = undefined; this.attributes = {}; this.data = {}; - this.id = null; - this.key = null; - this.style = null; - this.value = null; + this.id = undefined; + this.key = undefined; + this.style = undefined; + this.value = undefined; this.children = []; this.classList = []; this.eventListeners = {};