Updated unit tests.
@@ -1,4 +1,4 @@
-const mod = require("../h3.js"); +const mod = require('../h3.js'); const h3 = mod.h3; const h = mod.h;@@ -8,129 +8,131 @@ let count = 0;
let result = 0; const setCount = () => { - count = count + 2; - h3.dispatch("count/set", count); + count = count + 2; + h3.dispatch('count/set', count); }; -let hash = "#/c2"; +let hash = '#/c2'; const mockLocation = { - get hash() { - return hash; - }, - set hash(value) { - const event = new CustomEvent("hashchange"); - event.oldURL = hash; - event.newURL = value; - hash = value; - window.dispatchEvent(event); - }, + get hash() { + return hash; + }, + set hash(value) { + const event = new CustomEvent('hashchange'); + event.oldURL = hash; + event.newURL = value; + hash = value; + window.dispatchEvent(event); + }, }; const C1 = () => { - const parts = h3.route.parts; - const content = Object.keys(parts).map((key) => - h("li", `${key}: ${parts[key]}`) - ); - return h("ul.c1", content); + const parts = h3.route.parts; + const content = Object.keys(parts).map((key) => h('li', `${key}: ${parts[key]}`)); + return h('ul.c1', content); }; const C2 = () => { - const params = h3.route.params; - const content = Object.keys(params).map((key) => - h("li", `${key}: ${params[key]}`) - ); - return h("ul.c2", content); + const params = h3.route.params; + const content = Object.keys(params).map((key) => h('li', `${key}: ${params[key]}`)); + return h('ul.c2', content); }; -describe("h3 (Router)", () => { - beforeEach(async () => { - const preStart = () => (preStartCalled = true); - const postStart = () => (postStartCalled = true); - await h3.init({ - routes: { - "/c1/:a/:b/:c": C1, - "/c2": C2, - }, - location: mockLocation, - preStart: preStart, - postStart: postStart, - }); +describe('h3 (Router)', () => { + beforeEach(async () => { + const preStart = () => (preStartCalled = true); + const postStart = () => (postStartCalled = true); + await h3.init({ + routes: { + '/c1/:a/:b/:c': C1, + '/c2': C2, + }, + location: mockLocation, + preStart: preStart, + postStart: postStart, }); + }); - it("should support routing configuration at startup", () => { - expect(h3.route.def).toEqual("/c2"); - }); + it('should support routing configuration at startup', () => { + expect(h3.route.def).toEqual('/c2'); + }); - it("should support pre/post start hooks", () => { - expect(preStartCalled).toEqual(true); - expect(postStartCalled).toEqual(true); - }); + it('should support pre/post start hooks', () => { + expect(preStartCalled).toEqual(true); + expect(postStartCalled).toEqual(true); + }); - it("should support the capturing of parts within the current route", (done) => { - const sub = h3.on("$redraw", () => { - expect( - document.body.childNodes[0].childNodes[1].textContent - ).toEqual("b: 2"); - sub(); - done(); - }); - mockLocation.hash = "#/c1/1/2/3"; + it('should support the capturing of parts within the current route', (done) => { + const sub = h3.on('$redraw', () => { + expect(document.body.childNodes[0].childNodes[1].textContent).toEqual('b: 2'); + sub(); + done(); }); + mockLocation.hash = '#/c1/1/2/3'; + }); - it("should expose a navigateTo method to navigate to another path", (done) => { - const sub = h3.on("$redraw", () => { - expect( - document.body.childNodes[0].childNodes[1].textContent - ).toEqual("test2: 2"); - sub(); - done(); - }); - h3.navigateTo("/c2", { test1: 1, test2: 2 }); + it('should expose a navigateTo method to navigate to another path', (done) => { + const sub = h3.on('$redraw', () => { + expect(document.body.childNodes[0].childNodes[1].textContent).toEqual('test2: 2'); + sub(); + done(); }); + h3.navigateTo('/c2', { test1: 1, test2: 2 }); + }); - it("should throw an error if no route matches", async () => { - try { - await h3.init({ - element: document.body, - routes: { - "/c1/:a/:b/:c": () => h("div"), - "/c2": () => h("div"), - }, - }); - } catch (e) { - expect(e.message).toMatch(/No route matches/); - } - }); + it('should throw an error if no route matches', async () => { + try { + await h3.init({ + element: document.body, + routes: { + '/c1/:a/:b/:c': () => h('div'), + '/c2': () => h('div'), + }, + }); + } catch (e) { + expect(e.message).toMatch(/No route matches/); + } + }); - it("should execute setup and teardown methods", (done) => { - let redraws = 0; - C1.setup = (cstate) => { - cstate.result = cstate.result || 0; - cstate.sub = h3.on("count/set", (state, count) => { - cstate.result = count * count; - }); - }; - C1.teardown = (cstate) => { - cstate.sub(); - result = cstate.result; - return { result: cstate.result }; - }; - const sub = h3.on("$redraw", () => { - redraws++; - setCount(); - setCount(); - if (redraws === 1) { - expect(count).toEqual(4); - expect(result).toEqual(0); - h3.navigateTo("/c2"); - } - if (redraws === 2) { - expect(count).toEqual(8); - expect(result).toEqual(16); - delete C1.setup; - delete C1.teardown; - sub(); - done(); - } - }); - h3.navigateTo("/c1/a/b/c"); + it('should execute setup and teardown methods', (done) => { + let redraws = 0; + C1.setup = (cstate) => { + cstate.result = cstate.result || 0; + cstate.sub = h3.on('count/set', (state, count) => { + cstate.result = count * count; + }); + }; + C1.teardown = (cstate) => { + cstate.sub(); + result = cstate.result; + return { result: cstate.result }; + }; + const sub = h3.on('$redraw', () => { + redraws++; + setCount(); + setCount(); + if (redraws === 1) { + expect(count).toEqual(4); + expect(result).toEqual(0); + h3.navigateTo('/c2'); + } + if (redraws === 2) { + expect(count).toEqual(8); + expect(result).toEqual(16); + delete C1.setup; + delete C1.teardown; + sub(); + done(); + } }); + h3.navigateTo('/c1/a/b/c'); + }); + + it('should not navigate if setup method returns false', () => { + let redraws = 0; + const oldroute = h3.route; + C1.setup = () => { + return false; + }; + h3.navigateTo('/c1/a/b/c'); + expect(h3.route).toEqual(oldroute); + }); });
@@ -1,410 +1,417 @@
-const mod = require("../h3.js"); +const mod = require('../h3.js'); const h3 = mod.h3; const h = mod.h; -describe("VNode", () => { - it("should provide a from method to initialize itself from an object", () => { - const fn = () => true; - const obj = { - id: "test", - type: "input", - value: "AAA", - $html: "", - data: { a: "1", b: "2" }, - eventListeners: { click: fn }, - children: [], - props: { title: "test" }, - classList: ["a1", "a2"], - style: "padding: 2px", - }; - const vnode1 = h("br"); - vnode1.from(obj); - const vnode2 = h("input#test.a1.a2", { - value: "AAA", - $html: "", - data: { a: "1", b: "2" }, - onclick: fn, - title: "test", - style: "padding: 2px", - }); - expect(vnode1).toEqual(vnode2); +describe('VNode', () => { + it('should provide a from method to initialize itself from an object', () => { + const fn = () => true; + const obj = { + id: 'test', + type: 'input', + value: 'AAA', + $html: '', + data: { a: '1', b: '2' }, + eventListeners: { click: fn }, + children: [], + props: { title: 'test' }, + classList: ['a1', 'a2'], + style: 'padding: 2px', + }; + const vnode1 = h('br'); + vnode1.from(obj); + const vnode2 = h('input#test.a1.a2', { + value: 'AAA', + $html: '', + data: { a: '1', b: '2' }, + onclick: fn, + title: 'test', + style: 'padding: 2px', }); + expect(vnode1).toEqual(vnode2); + }); - it("should provide a render method able to render textual nodes", () => { - const createTextNode = jest.spyOn(document, "createTextNode"); - const vnode = h({ type: "#text", value: "test" }); - const node = vnode.render(); - expect(createTextNode).toHaveBeenCalledWith("test"); - expect(node.constructor).toEqual(Text); - }); + it('should provide a render method able to render textual nodes', () => { + const createTextNode = jest.spyOn(document, 'createTextNode'); + const vnode = h({ type: '#text', value: 'test' }); + const node = vnode.render(); + expect(createTextNode).toHaveBeenCalledWith('test'); + expect(node.constructor).toEqual(Text); + }); - it("should provide a render method able to render simple element nodes", () => { - const createElement = jest.spyOn(document, "createElement"); - const vnode = h("br"); - const node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("br"); - expect(node.constructor).toEqual(HTMLBRElement); - }); + it('should provide a render method able to render simple element nodes', () => { + const createElement = jest.spyOn(document, 'createElement'); + const vnode = h('br'); + const node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('br'); + expect(node.constructor).toEqual(HTMLBRElement); + }); - it("should provide a render method able to render element nodes with props and classes", () => { - const createElement = jest.spyOn(document, "createElement"); - const vnode = h("span.test1.test2", { title: "test", falsy: false }); - const node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("span"); - expect(node.constructor).toEqual(HTMLSpanElement); - expect(node.getAttribute("title")).toEqual("test"); - expect(node.classList.value).toEqual("test1 test2"); - }); + it('should provide a render method able to render element nodes with props and classes', () => { + const createElement = jest.spyOn(document, 'createElement'); + const vnode = h('span.test1.test2', { title: 'test', falsy: false }); + const node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('span'); + expect(node.constructor).toEqual(HTMLSpanElement); + expect(node.getAttribute('title')).toEqual('test'); + expect(node.classList.value).toEqual('test1 test2'); + }); - it("should provide a render method able to render element nodes with children", () => { - const vnode = h("ul", [h("li", "test1"), h("li", "test2")]); - const createElement = jest.spyOn(document, "createElement"); - const node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("ul"); - expect(createElement).toHaveBeenCalledWith("li"); - expect(node.constructor).toEqual(HTMLUListElement); - expect(node.childNodes.length).toEqual(2); - expect(node.childNodes[1].constructor).toEqual(HTMLLIElement); - expect(node.childNodes[0].childNodes[0].data).toEqual("test1"); + it('should provide a render method able to render element nodes with children', () => { + const vnode = h('ul', [h('li', 'test1'), h('li', 'test2')]); + const createElement = jest.spyOn(document, 'createElement'); + const node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('ul'); + expect(createElement).toHaveBeenCalledWith('li'); + expect(node.constructor).toEqual(HTMLUListElement); + expect(node.childNodes.length).toEqual(2); + expect(node.childNodes[1].constructor).toEqual(HTMLLIElement); + expect(node.childNodes[0].childNodes[0].data).toEqual('test1'); + }); + + it('should handle boolean props when redrawing', () => { + const vnode1 = h('input', { type: 'checkbox', checked: true }); + const node = vnode1.render(); + expect(node.checked).toEqual(true); + const vnode = h('input', { type: 'checkbox', checked: false }); + 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, + obj: { a: 1, b: 2 }, + arr: [1, 2, 3], + num: 2.3, + str: 'test', + s: '', + title: 'testing!', + value: false, + }); + const v2 = h('div', { + test: true, + obj: { a: 1, b: 2 }, + arr: [1, 2, 3], + s: '', + title: 'testing!', + value: 'true', }); + const n = v.render(); + expect(n.test).toEqual(true); + expect(n.obj).toEqual({ a: 1, b: 2 }); + expect(n.arr).toEqual([1, 2, 3]); + expect(n.num).toEqual(2.3); + expect(n.str).toEqual('test'); + expect(n.getAttribute('str')).toEqual('test'); + expect(n.s).toEqual(''); + expect(n.getAttribute('s')).toEqual(''); + expect(n.title).toEqual('testing!'); + expect(n.getAttribute('title')).toEqual('testing!'); + expect(n.value).toEqual(undefined); + expect(n.getAttribute('value')).toEqual(null); + v.redraw({ node: n, vnode: v2 }); + expect(n.getAttribute('value')).toEqual('true'); + v2.value = null; + v.redraw({ node: n, vnode: v2 }); + expect(n.getAttribute('value')).toEqual(''); + }); - it("should handle boolean props when redrawing", () => { - const vnode1 = h("input", { type: "checkbox", checked: true }); - const node = vnode1.render(); - expect(node.checked).toEqual(true); - const vnode = h("input", { type: "checkbox", checked: false }); - vnode1.redraw({ node, vnode }); - expect(node.checked).toEqual(false); - }); + it('should provide a render method able to render element nodes with a value', () => { + let vnode = h('input', { value: 'test' }); + const createElement = jest.spyOn(document, 'createElement'); + let node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('input'); + expect(node.constructor).toEqual(HTMLInputElement); + expect(node.value).toEqual('test'); + vnode = h('input', { value: null }); + node = vnode.render(); + expect(node.value).toEqual(''); + vnode = h('test', { value: 123 }); + node = vnode.render(); + expect(node.getAttribute('value')).toEqual('123'); + expect(node.value).toEqual(undefined); + }); - 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 provide a render method able to render element nodes with event handlers', () => { + const handler = () => { + console.log('test'); + }; + const vnode = h('button', { onclick: handler }); + const button = document.createElement('button'); + const createElement = jest.spyOn(document, 'createElement').mockImplementationOnce(() => { + return button; }); + const addEventListener = jest.spyOn(button, 'addEventListener'); + const node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('button'); + expect(node.constructor).toEqual(HTMLButtonElement); + expect(addEventListener).toHaveBeenCalledWith('click', handler); + }); - it("should handle non-string props as properties and not create attributes", () => { - const v = h("div", { - test: true, - obj: { a: 1, b: 2 }, - arr: [1, 2, 3], - num: 2.3, - str: "test", - s: "", - title: "testing!", - value: false, - }); - const v2 = h("div", { - test: true, - obj: { a: 1, b: 2 }, - arr: [1, 2, 3], - s: "", - title: "testing!", - value: "true", - }); - const n = v.render(); - expect(n.test).toEqual(true); - expect(n.obj).toEqual({ a: 1, b: 2 }); - expect(n.arr).toEqual([1, 2, 3]); - expect(n.num).toEqual(2.3); - expect(n.str).toEqual("test"); - expect(n.getAttribute("str")).toEqual("test"); - expect(n.s).toEqual(""); - expect(n.getAttribute("s")).toEqual(""); - expect(n.title).toEqual("testing!"); - expect(n.getAttribute("title")).toEqual("testing!"); - expect(n.value).toEqual(undefined); - expect(n.getAttribute("value")).toEqual(null); - v.redraw({ node: n, vnode: v2 }); - expect(n.getAttribute("value")).toEqual("true"); - v2.value = null; - v.redraw({ node: n, vnode: v2 }); - expect(n.getAttribute("value")).toEqual(""); + it('it should provide a render method able to render elements with special props', () => { + const vnode = h('div', { + id: 'test', + style: 'margin: auto;', + data: { test: 'aaa' }, + $html: '<p>Hello!</p>', }); + const createElement = jest.spyOn(document, 'createElement'); + const node = vnode.render(); + expect(createElement).toHaveBeenCalledWith('div'); + expect(node.constructor).toEqual(HTMLDivElement); + expect(node.style.cssText).toEqual('margin: auto;'); + expect(node.id).toEqual('test'); + expect(node.dataset['test']).toEqual('aaa'); + expect(node.childNodes[0].textContent).toEqual('Hello!'); + }); - it("should provide a render method able to render element nodes with a value", () => { - let vnode = h("input", { value: "test" }); - const createElement = jest.spyOn(document, "createElement"); - let node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("input"); - expect(node.constructor).toEqual(HTMLInputElement); - expect(node.value).toEqual("test"); - vnode = h("input", { value: null }); - node = vnode.render(); - expect(node.value).toEqual(""); - vnode = h("test", { value: 123 }); - node = vnode.render(); - expect(node.getAttribute("value")).toEqual("123"); - expect(node.value).toEqual(undefined); - }); + it('should provide a redraw method that is able to add new DOM nodes', () => { + const oldvnode = h('div#test', h('span')); + const newvnodeNoChildren = h('div'); + const newvnode = h('div', [h('span#a'), h('span')]); + const node = oldvnode.render(); + const span = node.childNodes[0]; + oldvnode.redraw({ node: node, vnode: newvnodeNoChildren }); + expect(oldvnode.children.length).toEqual(0); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(oldvnode.children.length).toEqual(2); + expect(node.childNodes.length).toEqual(2); + expect(node.childNodes[0].id).toEqual('a'); + expect(span).toEqual(node.childNodes[1]); + }); - it("should provide a render method able to render element nodes with event handlers", () => { - const handler = () => { - console.log("test"); - }; - const vnode = h("button", { onclick: handler }); - const button = document.createElement("button"); - const createElement = jest - .spyOn(document, "createElement") - .mockImplementationOnce(() => { - return button; - }); - const addEventListener = jest.spyOn(button, "addEventListener"); - const node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("button"); - expect(node.constructor).toEqual(HTMLButtonElement); - expect(addEventListener).toHaveBeenCalledWith("click", handler); - }); + it('should provide a redraw method that is able to remove existing DOM nodes', () => { + let oldvnode = h('div', [h('span#a'), h('span')]); + let newvnode = h('div', [h('span')]); + let node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(oldvnode.children.length).toEqual(1); + expect(node.childNodes.length).toEqual(1); + oldvnode = h('div.test-children', [h('span.a'), h('span.b')]); + node = oldvnode.render(); + newvnode = h('div.test-children', [h('div.c')]); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(oldvnode.children.length).toEqual(1); + expect(node.childNodes.length).toEqual(1); + expect(oldvnode.children[0].classList[0]).toEqual('c'); + }); - it("it should provide a render method able to render elements with special props", () => { - const vnode = h("div", { - id: "test", - style: "margin: auto;", - data: { test: "aaa" }, - $html: "<p>Hello!</p>", - }); - const createElement = jest.spyOn(document, "createElement"); - const node = vnode.render(); - expect(createElement).toHaveBeenCalledWith("div"); - expect(node.constructor).toEqual(HTMLDivElement); - expect(node.style.cssText).toEqual("margin: auto;"); - expect(node.id).toEqual("test"); - expect(node.dataset["test"]).toEqual("aaa"); - expect(node.childNodes[0].textContent).toEqual("Hello!"); - }); + it('should provide a redraw method that is able to figure out differences in children', () => { + const oldvnode = h('div', [h('span', 'a'), h('span'), h('span', 'b')]); + const newvnode = h('div', [h('span', 'a'), h('span', 'c'), h('span', 'b')]); + const node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(node.childNodes[1].textContent).toEqual('c'); + }); - it("should provide a redraw method that is able to add new DOM nodes", () => { - const oldvnode = h("div#test", h("span")); - const newvnodeNoChildren = h("div"); - const newvnode = h("div", [h("span#a"), h("span")]); - const node = oldvnode.render(); - const span = node.childNodes[0]; - oldvnode.redraw({ node: node, vnode: newvnodeNoChildren }); - expect(oldvnode.children.length).toEqual(0); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(oldvnode.children.length).toEqual(2); - expect(node.childNodes.length).toEqual(2); - expect(node.childNodes[0].id).toEqual("a"); - expect(span).toEqual(node.childNodes[1]); - }); + it('should provide a redraw method that is able to figure out differences in existing children', () => { + const oldvnode = h('div', [h('span.test', 'a'), h('span.test', 'b'), h('span.test', 'c')]); + const newvnode = h('div', [h('span.test', 'a'), h('span.test1', 'b'), h('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 remove existing DOM nodes", () => { - let oldvnode = h("div", [h("span#a"), h("span")]); - let newvnode = h("div", [h("span")]); - let node = oldvnode.render(); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(oldvnode.children.length).toEqual(1); - expect(node.childNodes.length).toEqual(1); - oldvnode = h("div.test-children", [h("span.a"), h("span.b")]); - node = oldvnode.render(); - newvnode = h("div.test-children", [h("div.c")]); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(oldvnode.children.length).toEqual(1); - expect(node.childNodes.length).toEqual(1); - expect(oldvnode.children[0].classList[0]).toEqual("c"); - }); + it('should provide a redraw method that is able to update different props', () => { + const oldvnode = h('span', { title: 'a', something: 'b' }); + const newvnode = h('span', { title: 'b', id: 'bbb' }); + const node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(node.getAttribute('title')).toEqual('b'); + expect(node.getAttribute('id')).toEqual('bbb'); + expect(node.hasAttribute('something')).toEqual(false); + }); - it("should provide a redraw method that is able to figure out differences in children", () => { - const oldvnode = h("div", [h("span", "a"), h("span"), h("span", "b")]); - const newvnode = h("div", [ - h("span", "a"), - h("span", "c"), - h("span", "b"), - ]); - const node = oldvnode.render(); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(node.childNodes[1].textContent).toEqual("c"); - }); + it('should provide a redraw method that is able to update different classes', () => { + const oldvnode = h('span.a.b', { title: 'b' }); + const newvnode = h('span.a.c', { title: 'b' }); + const node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(node.classList.value).toEqual('a c'); + }); - it("should provide a redraw method that is able to figure out differences in existing children", () => { - const oldvnode = h("div", [ - h("span.test", "a"), - h("span.test", "b"), - h("span.test", "c"), - ]); - const newvnode = h("div", [ - h("span.test", "a"), - h("span.test1", "b"), - h("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 redraw method to detect changed nodes if they have different elements', () => { + const oldvnode = h('span.c', { title: 'b' }); + const newvnode = h('div.c', { title: 'b' }); + const container = document.createElement('div'); + const node = oldvnode.render(); + container.appendChild(node); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(node).not.toEqual(container.childNodes[0]); + expect(node.constructor).toEqual(HTMLSpanElement); + expect(container.childNodes[0].constructor).toEqual(HTMLDivElement); + }); - it("should provide a redraw method that is able to update different props", () => { - const oldvnode = h("span", { title: "a", something: "b" }); - const newvnode = h("span", { title: "b", id: "bbb" }); - const node = oldvnode.render(); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(node.getAttribute("title")).toEqual("b"); - expect(node.getAttribute("id")).toEqual("bbb"); - expect(node.hasAttribute("something")).toEqual(false); - }); + it('should provide redraw method to detect position changes in child nodes', () => { + const v1 = h('ul', [h('li.a'), h('li.b'), h('li.c'), h('li.d')]); + const v2 = h('ul', [h('li.c'), h('li.b'), h('li.a'), h('li.d')]); + const n = v1.render(); + expect(n.childNodes[0].classList[0]).toEqual('a'); + v1.redraw({ node: n, vnode: v2 }); + expect(n.childNodes[0].classList[0]).toEqual('c'); + }); - it("should provide a redraw method that is able to update different classes", () => { - const oldvnode = h("span.a.b", { title: "b" }); - const newvnode = h("span.a.c", { title: "b" }); - const node = oldvnode.render(); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(node.classList.value).toEqual("a c"); - }); + it('should optimize insertion and deletions when redrawing if all old/new children exist', () => { + const v = h('div', h('a'), h('d')); + const vnode = h('div', h('a'), h('b'), h('c'), h('d')); + const node = v.render(); + v.redraw({ node, vnode }); + expect(v.children.length).toEqual(4); + }); - it("should provide redraw method to detect changed nodes if they have different elements", () => { - const oldvnode = h("span.c", { title: "b" }); - const newvnode = h("div.c", { title: "b" }); - const container = document.createElement("div"); - const node = oldvnode.render(); - container.appendChild(node); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(node).not.toEqual(container.childNodes[0]); - expect(node.constructor).toEqual(HTMLSpanElement); - expect(container.childNodes[0].constructor).toEqual(HTMLDivElement); - }); + it('should provide redraw method to detect changed nodes if they have different node types', () => { + const oldvnode = h('span.c', { title: 'b' }); + const newvnode = h({ type: '#text', value: 'test' }); + const container = document.createElement('div'); + const node = oldvnode.render(); + container.appendChild(node); + expect(node.constructor).toEqual(HTMLSpanElement); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(node).not.toEqual(container.childNodes[0]); + expect(container.childNodes[0].data).toEqual('test'); + }); - it("should provide redraw method to detect position changes in child nodes", () => { - const v1 = h("ul", [h("li.a"), h("li.b"), h("li.c"), h("li.d")]); - const v2 = h("ul", [h("li.c"), h("li.b"), h("li.a"), h("li.d")]); - const n = v1.render(); - expect(n.childNodes[0].classList[0]).toEqual("a"); - v1.redraw({ node: n, vnode: v2 }); - expect(n.childNodes[0].classList[0]).toEqual("c"); - }); + it('should provide redraw method to detect changed nodes if they have different text', () => { + const oldvnode = h({ type: '#text', value: 'test1' }); + const newvnode = h({ type: '#text', value: 'test2' }); + const container = document.createElement('div'); + const node = oldvnode.render(); + container.appendChild(node); + expect(node.data).toEqual('test1'); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(container.childNodes[0].data).toEqual('test2'); + }); - it("should optimize insertion and deletions when redrawing if all old/new children exist", () => { - const v = h("div", h("a"), h("d")); - const vnode = h("div", h("a"), h("b"), h("c"), h("d")); - const node = v.render(); - v.redraw({ node, vnode }); - expect(v.children.length).toEqual(4); - }); + it('should provide redraw method to detect changed nodes and recurse', () => { + const oldvnode = h('ul.c', { title: 'b' }, [h('li#aaa'), h('li#bbb'), h('li#ccc')]); + const newvnode = h('ul.c', { title: 'b' }, [h('li#aaa'), h('li#ccc')]); + const node = oldvnode.render(); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(node.childNodes.length).toEqual(2); + expect(node.childNodes[0].getAttribute('id')).toEqual('aaa'); + expect(node.childNodes[1].getAttribute('id')).toEqual('ccc'); + }); - it("should provide redraw method to detect changed nodes if they have different node types", () => { - const oldvnode = h("span.c", { title: "b" }); - const newvnode = h({ type: "#text", value: "test" }); - const container = document.createElement("div"); - const node = oldvnode.render(); - container.appendChild(node); - expect(node.constructor).toEqual(HTMLSpanElement); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(node).not.toEqual(container.childNodes[0]); - expect(container.childNodes[0].data).toEqual("test"); + it('should provide a redraw method able to detect specific changes to style, data, value, props, $onrender and eventListeners', () => { + const fn = () => false; + const oldvnode = h('input', { + style: 'margin: auto;', + data: { a: 111, b: 222, d: 444 }, + value: null, + title: 'test', + label: 'test', + onkeydown: () => true, + onclick: () => true, + onkeypress: () => true, }); - - it("should provide redraw method to detect changed nodes if they have different text", () => { - const oldvnode = h({ type: "#text", value: "test1" }); - const newvnode = h({ type: "#text", value: "test2" }); - const container = document.createElement("div"); - const node = oldvnode.render(); - container.appendChild(node); - expect(node.data).toEqual("test1"); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(container.childNodes[0].data).toEqual("test2"); + const newvnode = h('input', { + style: false, + data: { a: 111, b: 223, c: 333 }, + title: 'test #2', + label: 'test', + something: false, + somethingElse: { test: 1 }, + value: 0, + placeholder: 'test', + onkeydown: () => true, + onkeypress: () => false, + $onrender: () => true, + onhover: () => true, }); - - it("should provide redraw method to detect changed nodes and recurse", () => { - const oldvnode = h("ul.c", { title: "b" }, [ - h("li#aaa"), - h("li#bbb"), - h("li#ccc"), - ]); - const newvnode = h("ul.c", { title: "b" }, [h("li#aaa"), h("li#ccc")]); - const node = oldvnode.render(); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(node.childNodes.length).toEqual(2); - expect(node.childNodes[0].getAttribute("id")).toEqual("aaa"); - expect(node.childNodes[1].getAttribute("id")).toEqual("ccc"); + const newvnode2 = h('input', { + style: false, + data: { a: 111, b: 223, c: 333 }, + title: 'test #2', + label: 'test', + something: false, + somethingElse: { test: 1 }, + placeholder: 'test', + onkeydown: () => true, + onkeypress: () => false, + $onrender: () => true, + onhover: () => true, }); + const container = document.createElement('div'); + const node = oldvnode.render(); + expect(node.value).toEqual(''); + container.appendChild(node); + oldvnode.redraw({ node: node, vnode: newvnode }); + expect(oldvnode).toEqual(newvnode); + expect(node.style.cssText).toEqual(''); + expect(node.dataset['a']).toEqual('111'); + expect(node.dataset['c']).toEqual('333'); + expect(node.dataset['b']).toEqual('223'); + expect(node.dataset['d']).toEqual(undefined); + expect(node.something).toEqual(false); + expect(node.getAttribute('title')).toEqual('test #2'); + expect(node.getAttribute('placeholder')).toEqual('test'); + expect(node.value).toEqual('0'); + oldvnode.redraw({ node, vnode: newvnode2 }); + expect(node.value).toEqual(''); + }); - it("should provide a redraw method able to detect specific changes to style, data, value, props, $onrender and eventListeners", () => { - const fn = () => false; - const oldvnode = h("input", { - style: "margin: auto;", - data: { a: 111, b: 222, d: 444 }, - value: "Test...", - title: "test", - label: "test", - onkeydown: () => true, - onclick: () => true, - onkeypress: () => true, - }); - const newvnode = h("input", { - style: false, - data: { a: 111, b: 223, c: 333 }, - title: "test #2", - label: "test", - placeholder: "test", - onkeydown: () => true, - onkeypress: () => false, - $onrender: () => true, - onhover: () => true, - }); - const container = document.createElement("div"); - const node = oldvnode.render(); - container.appendChild(node); - oldvnode.redraw({ node: node, vnode: newvnode }); - expect(oldvnode).toEqual(newvnode); - expect(node.style.cssText).toEqual(""); - expect(node.dataset["a"]).toEqual("111"); - expect(node.dataset["c"]).toEqual("333"); - expect(node.dataset["b"]).toEqual("223"); - expect(node.dataset["d"]).toEqual(undefined); - expect(node.getAttribute("title")).toEqual("test #2"); - expect(node.getAttribute("placeholder")).toEqual("test"); - expect(node.value).toEqual(""); - }); + it('should handle value property/attribute for non-input fields', () => { + const v = h('test', { value: null }); + const n = v.render(); + expect(n.value).toEqual(undefined); + expect(n.getAttribute('value')).toEqual(null); + }); - it("should provide a redraw method able to detect changes in child content", () => { - const v1 = h("ul", [h("li", "a"), h("li", "b")]); - const n1 = v1.render(); - const v2 = h("ul", { - $html: "<li>a</li><li>b</li>", - $onrender: (node) => node.classList.add("test"), - }); - const v3 = h("ul", [h("li", "a")]); - const v4 = h("ul", [h("li", "b")]); - const n2 = v2.render(); - const n3 = v3.render(); - expect(n2.childNodes[0].childNodes[0].data).toEqual( - n1.childNodes[0].childNodes[0].data - ); - v1.redraw({ node: n1, vnode: v2 }); - expect(n1.classList[0]).toEqual("test"); - expect(v1).toEqual(v2); - v3.redraw({ node: n3, vnode: v4 }); - expect(v3).toEqual(v4); + it('should provide a redraw method able to detect changes in child content', () => { + const v1 = h('ul', [h('li', 'a'), h('li', 'b')]); + const n1 = v1.render(); + const v2 = h('ul', { + $html: '<li>a</li><li>b</li>', + $onrender: (node) => node.classList.add('test'), }); + const v3 = h('ul', [h('li', 'a')]); + const v4 = h('ul', [h('li', 'b')]); + const n2 = v2.render(); + const n3 = v3.render(); + expect(n2.childNodes[0].childNodes[0].data).toEqual(n1.childNodes[0].childNodes[0].data); + v1.redraw({ node: n1, vnode: v2 }); + expect(n1.classList[0]).toEqual('test'); + expect(v1).toEqual(v2); + v3.redraw({ node: n3, vnode: v4 }); + expect(v3).toEqual(v4); + }); - it("should execute $onrender callbacks whenever a child node is added to the DOM", async () => { - let n; - const $onrender = (node) => { - n = node; - }; - const vn1 = h("ul", [h("li")]); - const vn2 = h("ul", [h("li"), h("li.vn2", { $onrender })]); - const n1 = vn1.render(); - vn1.redraw({ node: n1, vnode: vn2 }); - expect(n.classList.value).toEqual("vn2"); - const vn3 = h("ul", [h("span.vn3", { $onrender })]); - vn1.redraw({ node: n1, vnode: vn3 }); - expect(n.classList.value).toEqual("vn3"); - const rc = () => h("div.rc", { $onrender }); - await h3.init(rc); - expect(n.classList.value).toEqual("rc"); - const rc2 = () => vn2; - await h3.init(rc2); - expect(n.classList.value).toEqual("vn2"); - }); + it('should execute $onrender callbacks whenever a child node is added to the DOM', async () => { + let n; + const $onrender = (node) => { + n = node; + }; + const vn1 = h('ul', [h('li')]); + const vn2 = h('ul', [h('li'), h('li.vn2', { $onrender })]); + const n1 = vn1.render(); + vn1.redraw({ node: n1, vnode: vn2 }); + expect(n.classList.value).toEqual('vn2'); + const vn3 = h('ul', [h('span.vn3', { $onrender })]); + vn1.redraw({ node: n1, vnode: vn3 }); + expect(n.classList.value).toEqual('vn3'); + const rc = () => h('div.rc', { $onrender }); + await h3.init(rc); + expect(n.classList.value).toEqual('rc'); + const rc2 = () => vn2; + await h3.init(rc2); + expect(n.classList.value).toEqual('vn2'); + }); });
@@ -8128,7 +8128,7 @@ </ul>
</div> <div id="footer"> - <p><span class="copy"></span> Fabio Cevasco – October 18, 2020</p> + <p><span class="copy"></span> Fabio Cevasco – October 25, 2020</p> <p><span>Powered by</span> <a href="https://h3rald.com/hastyscribe"><span class="hastyscribe"></span></a></p> </div> </div>
@@ -20,6 +20,8 @@ }
return true; }; +const blank = (v) => [undefined, null].includes(v); + const equal = (obj1, obj2) => { if ((obj1 === null && obj2 === null) || (obj1 === undefined && obj2 === undefined)) { return true;@@ -235,7 +237,7 @@ if (this.type === '#text') {
return document.createTextNode(this.value); } const node = document.createElement(this.type); - if (this.id) { + if (!blank(this.id)) { node.id = this.id; } Object.keys(this.props).forEach((p) => {@@ -255,10 +257,10 @@ node.addEventListener(event, this.eventListeners[event]);
}); // Value if (this.value) { - if (['textarea', 'input'].includes(this.type)) { + if (['textarea', 'input', 'option', 'button'].includes(this.type)) { node.value = this.value; } else { - node.setAttribute('value', this.value); + node.setAttribute('value', this.value.toString()); } } // Style@@ -267,7 +269,7 @@ node.style.cssText = this.style;
} // Classes this.classList.forEach((c) => { - node.classList.add(c); + c && node.classList.add(c); }); // Data Object.keys(this.data).forEach((key) => {@@ -303,16 +305,16 @@ return;
} // ID if (oldvnode.id !== newvnode.id) { - node.id = newvnode.id || ''; + node.id = newvnode.id; oldvnode.id = newvnode.id; } // Value if (oldvnode.value !== newvnode.value) { oldvnode.value = newvnode.value; - if (['textarea', 'input'].includes(oldvnode.type)) { - node.value = newvnode.value || ''; + if (['textarea', 'input', 'option', 'button'].includes(oldvnode.type)) { + node.value = blank(newvnode.value) ? '' : newvnode.value.toString(); } else { - node.setAttribute('value', newvnode.value || ''); + node.setAttribute('value', blank(newvnode.value) ? '' : newvnode.value.toString()); } } // Classes@@ -323,7 +325,7 @@ node.classList.remove(c);
} }); newvnode.classList.forEach((c) => { - if (!oldvnode.classList.includes(c)) { + if (c && !oldvnode.classList.includes(c)) { node.classList.add(c); } });@@ -368,9 +370,12 @@ }
} }); Object.keys(newvnode.props).forEach((a) => { - if (!oldvnode.props[a] && newvnode.props[a]) { + if (blank(oldvnode.props[a]) && !blank(newvnode.props[a])) { oldvnode.props[a] = newvnode.props[a]; - if (['string', 'number'].includes(typeof newvnode.props[a])) { + node[a] = newvnode.props[a]; + if (typeof newvnode.props[a] === 'boolean') { + node.setAttribute(a, ''); + } else if (['string', 'number'].includes(typeof newvnode.props[a])) { node.setAttribute(a, newvnode.props[a]); } }@@ -558,6 +563,7 @@ const query = rawQuery && rawQuery[1] ? rawQuery[1] : '';
const pathParts = path.split('/').slice(1); let parts = {}; + let newRoute; for (let def of Object.keys(this.routes)) { let routeParts = def.split('/').slice(1); let match = true;@@ -574,11 +580,11 @@ }
index++; } if (match) { - this.route = new Route({ query, path, def, parts }); + newRoute = new Route({ query, path, def, parts }); break; } } - if (!this.route) { + if (!newRoute) { throw new Error(`[Router] No route matches '${fragment}'`); } // Old route component teardown@@ -588,13 +594,15 @@ const oldRouteComponent = this.routes[oldRoute.def];
state = (oldRouteComponent.teardown && (await oldRouteComponent.teardown(oldRouteComponent.state))) || state; } // New route component setup - const newRouteComponent = this.routes[this.route.def]; + const newRouteComponent = this.routes[newRoute.def]; newRouteComponent.state = state; if (newRouteComponent.setup) { if ((await newRouteComponent.setup(newRouteComponent.state)) === false) { + // Abort navigation return; } } + this.route = newRoute; // Redrawing... redrawing = true; this.store.dispatch('$navigation', this.route);
@@ -20,6 +20,8 @@ }
return true; }; +const blank = (v) => [undefined, null].includes(v); + const equal = (obj1, obj2) => { if ((obj1 === null && obj2 === null) || (obj1 === undefined && obj2 === undefined)) { return true;@@ -235,7 +237,7 @@ if (this.type === '#text') {
return document.createTextNode(this.value); } const node = document.createElement(this.type); - if (this.id) { + if (!blank(this.id)) { node.id = this.id; } Object.keys(this.props).forEach((p) => {@@ -255,10 +257,10 @@ node.addEventListener(event, this.eventListeners[event]);
}); // Value if (this.value) { - if (['textarea', 'input'].includes(this.type)) { + if (['textarea', 'input', 'option', 'button'].includes(this.type)) { node.value = this.value; } else { - node.setAttribute('value', this.value); + node.setAttribute('value', this.value.toString()); } } // Style@@ -267,7 +269,7 @@ node.style.cssText = this.style;
} // Classes this.classList.forEach((c) => { - node.classList.add(c); + c && node.classList.add(c); }); // Data Object.keys(this.data).forEach((key) => {@@ -303,16 +305,16 @@ return;
} // ID if (oldvnode.id !== newvnode.id) { - node.id = newvnode.id || ''; + node.id = newvnode.id; oldvnode.id = newvnode.id; } // Value if (oldvnode.value !== newvnode.value) { oldvnode.value = newvnode.value; - if (['textarea', 'input'].includes(oldvnode.type)) { - node.value = newvnode.value || ''; + if (['textarea', 'input', 'option', 'button'].includes(oldvnode.type)) { + node.value = blank(newvnode.value) ? '' : newvnode.value.toString(); } else { - node.setAttribute('value', newvnode.value || ''); + node.setAttribute('value', blank(newvnode.value) ? '' : newvnode.value.toString()); } } // Classes@@ -323,7 +325,7 @@ node.classList.remove(c);
} }); newvnode.classList.forEach((c) => { - if (!oldvnode.classList.includes(c)) { + if (c && !oldvnode.classList.includes(c)) { node.classList.add(c); } });@@ -368,9 +370,12 @@ }
} }); Object.keys(newvnode.props).forEach((a) => { - if (!oldvnode.props[a] && newvnode.props[a]) { + if (blank(oldvnode.props[a]) && !blank(newvnode.props[a])) { oldvnode.props[a] = newvnode.props[a]; - if (['string', 'number'].includes(typeof newvnode.props[a])) { + node[a] = newvnode.props[a]; + if (typeof newvnode.props[a] === 'boolean') { + node.setAttribute(a, ''); + } else if (['string', 'number'].includes(typeof newvnode.props[a])) { node.setAttribute(a, newvnode.props[a]); } }@@ -558,6 +563,7 @@ const query = rawQuery && rawQuery[1] ? rawQuery[1] : '';
const pathParts = path.split('/').slice(1); let parts = {}; + let newRoute; for (let def of Object.keys(this.routes)) { let routeParts = def.split('/').slice(1); let match = true;@@ -574,11 +580,11 @@ }
index++; } if (match) { - this.route = new Route({ query, path, def, parts }); + newRoute = new Route({ query, path, def, parts }); break; } } - if (!this.route) { + if (!newRoute) { throw new Error(`[Router] No route matches '${fragment}'`); } // Old route component teardown@@ -588,13 +594,15 @@ const oldRouteComponent = this.routes[oldRoute.def];
state = (oldRouteComponent.teardown && (await oldRouteComponent.teardown(oldRouteComponent.state))) || state; } // New route component setup - const newRouteComponent = this.routes[this.route.def]; + const newRouteComponent = this.routes[newRoute.def]; newRouteComponent.state = state; if (newRouteComponent.setup) { if ((await newRouteComponent.setup(newRouteComponent.state)) === false) { + // Abort navigation return; } } + this.route = newRoute; // Redrawing... redrawing = true; this.store.dispatch('$navigation', this.route);
@@ -20,6 +20,8 @@ }
return true; }; +const blank = (v) => [undefined, null].includes(v); + const equal = (obj1, obj2) => { if ((obj1 === null && obj2 === null) || (obj1 === undefined && obj2 === undefined)) { return true;@@ -235,7 +237,7 @@ if (this.type === '#text') {
return document.createTextNode(this.value); } const node = document.createElement(this.type); - if (this.id) { + if (!blank(this.id)) { node.id = this.id; } Object.keys(this.props).forEach((p) => {@@ -255,10 +257,10 @@ node.addEventListener(event, this.eventListeners[event]);
}); // Value if (this.value) { - if (['textarea', 'input'].includes(this.type)) { + if (['textarea', 'input', 'option', 'button'].includes(this.type)) { node.value = this.value; } else { - node.setAttribute('value', this.value); + node.setAttribute('value', this.value.toString()); } } // Style@@ -267,7 +269,7 @@ node.style.cssText = this.style;
} // Classes this.classList.forEach((c) => { - node.classList.add(c); + c && node.classList.add(c); }); // Data Object.keys(this.data).forEach((key) => {@@ -303,16 +305,16 @@ return;
} // ID if (oldvnode.id !== newvnode.id) { - node.id = newvnode.id || ''; + node.id = newvnode.id; oldvnode.id = newvnode.id; } // Value if (oldvnode.value !== newvnode.value) { oldvnode.value = newvnode.value; - if (['textarea', 'input'].includes(oldvnode.type)) { - node.value = newvnode.value || ''; + if (['textarea', 'input', 'option', 'button'].includes(oldvnode.type)) { + node.value = blank(newvnode.value) ? '' : newvnode.value.toString(); } else { - node.setAttribute('value', newvnode.value || ''); + node.setAttribute('value', blank(newvnode.value) ? '' : newvnode.value.toString()); } } // Classes@@ -323,7 +325,7 @@ node.classList.remove(c);
} }); newvnode.classList.forEach((c) => { - if (!oldvnode.classList.includes(c)) { + if (c && !oldvnode.classList.includes(c)) { node.classList.add(c); } });@@ -368,9 +370,12 @@ }
} }); Object.keys(newvnode.props).forEach((a) => { - if (!oldvnode.props[a] && newvnode.props[a]) { + if (blank(oldvnode.props[a]) && !blank(newvnode.props[a])) { oldvnode.props[a] = newvnode.props[a]; - if (['string', 'number'].includes(typeof newvnode.props[a])) { + node[a] = newvnode.props[a]; + if (typeof newvnode.props[a] === 'boolean') { + node.setAttribute(a, ''); + } else if (['string', 'number'].includes(typeof newvnode.props[a])) { node.setAttribute(a, newvnode.props[a]); } }@@ -558,6 +563,7 @@ const query = rawQuery && rawQuery[1] ? rawQuery[1] : '';
const pathParts = path.split('/').slice(1); let parts = {}; + let newRoute; for (let def of Object.keys(this.routes)) { let routeParts = def.split('/').slice(1); let match = true;@@ -574,11 +580,11 @@ }
index++; } if (match) { - this.route = new Route({ query, path, def, parts }); + newRoute = new Route({ query, path, def, parts }); break; } } - if (!this.route) { + if (!newRoute) { throw new Error(`[Router] No route matches '${fragment}'`); } // Old route component teardown@@ -588,13 +594,15 @@ const oldRouteComponent = this.routes[oldRoute.def];
state = (oldRouteComponent.teardown && (await oldRouteComponent.teardown(oldRouteComponent.state))) || state; } // New route component setup - const newRouteComponent = this.routes[this.route.def]; + const newRouteComponent = this.routes[newRoute.def]; newRouteComponent.state = state; if (newRouteComponent.setup) { if ((await newRouteComponent.setup(newRouteComponent.state)) === false) { + // Abort navigation return; } } + this.route = newRoute; // Redrawing... redrawing = true; this.store.dispatch('$navigation', this.route);
@@ -1,1 +1,1 @@
-{"version":3,"sources":["0"],"names":["checkProperties","obj1","obj2","Object","keys","length","key","equal","undefined","constructor","toString","String","Number","Boolean","includes","Array","i","selectorRegex","PATCH","INSERT","DELETE","$onrenderCallbacks","VNode","[object Object]","args","this","type","props","data","id","$html","$onrender","style","value","children","classList","eventListeners","Error","vnode","processSelector","from","processVNodeObject","selector","isArray","Function","processChildren","processProperties","slice","concat","a","b","attrs","filter","startsWith","forEach","match","classes","split","arg","map","c","document","createTextNode","node","createElement","p","setAttribute","removeAttribute","event","addEventListener","cssText","add","dataset","cnode","render","appendChild","push","innerHTML","newvnode","oldvnode","renderedNode","parentNode","replaceChild","remove","removeEventListener","childMap","mapChildren","resultMap","count","checkmap","redraw","childNodes","splice","insertBefore","removeChild","vtarget","target","newList","oldList","nIdx","op","oIdx","oldNodesFound","Store","events","state","dispatch","cb","Route","path","def","query","parts","params","name","decodeURIComponent","Router","element","routes","store","location","window","route","processPath","async","oldRoute","fragment","newURL","hash","replace","rawQuery","pathParts","routeParts","index","rP","pP","oldRouteComponent","teardown","newRouteComponent","setup","redrawing","firstChild","setRedraw","cbk","scrollTo","encodeURIComponent","join","h","h3","router","init","config","modules","preStart","postStart","/","body","Element","Promise","resolve","then","start","navigateTo","defineProperty","get","on","setRedrawing","screen","display","fn"],"mappings":";;;;;;;AAOA,MAAMA,gBAAkB,CAACC,EAAMC,KAC7B,GAAIC,OAAOC,KAAKH,GAAMI,SAAWF,OAAOC,KAAKF,GAAMG,OACjD,OAAO,EAET,IAAK,MAAMC,KAAOL,EAAM,CACtB,KAAMK,KAAOJ,GACX,OAAO,EAET,IAAKK,MAAMN,EAAKK,GAAMJ,EAAKI,IACzB,OAAO,EAGX,OAAO,GAGHC,MAAQ,CAACN,EAAMC,KACnB,GAAc,OAATD,GAA0B,OAATC,QAA4BM,IAATP,QAA+BO,IAATN,EAC7D,OAAO,EAET,QAAcM,IAATP,QAA+BO,IAATN,QAA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AS,EAAG5B,MAAAA,EAAO6B,QAAAA,EAAS/B,SAAAA,MAC7B,IAAK+B,GAA8B,mBAAZA,EACrB,MAAM,IAAInI,MAAM,8CAElB,GAAIsG,GAA0B,mBAAVA,EAClB,MAAM,IAAItG,MAAM,iDAElB,GAAIoG,GAAgC,mBAAbA,EACrB,MAAM,IAAIpG,MAAM,oDAElB,MAAMoI,EAAKD,EAOX,OANI7B,IACF8B,EAAG9B,MAAQA,GAETF,IACFgC,EAAGhC,SAAWA,GAETgC,kBAGMrB","file":"h3.js"}+{"version":3,"sources":["0"],"names":["checkProperties","obj1","obj2","Object","keys","length","key","equal","blank","v","undefined","includes","constructor","toString","String","Number","Boolean","Array","i","selectorRegex","PATCH","INSERT","DELETE","$onrenderCallbacks","VNode","[object Object]","args","this","type","props","data","id","$html","$onrender","style","value","children","classList","eventListeners","Error","vnode","processSelector","from","processVNodeObject","selector","isArray","Function","processChildren","processProperties","slice","concat","a","b","attrs","filter","startsWith","forEach","match","classes","split","arg","map","c","document","createTextNode","node","createElement","p","setAttribute","removeAttribute","event","addEventListener","cssText","add","dataset","cnode","render","appendChild","push","innerHTML","newvnode","oldvnode","renderedNode","parentNode","replaceChild","remove","removeEventListener","childMap","mapChildren","resultMap","count","checkmap","redraw","childNodes","splice","insertBefore","removeChild","vtarget","target","newList","oldList","nIdx","op","oIdx","oldNodesFound","Store","events","state","dispatch","cb","Route","path","def","query","parts","params","name","decodeURIComponent","Router","element","routes","store","location","window","route","processPath","async","oldRoute","fragment","newURL","hash","replace","rawQuery","pathParts","newRoute","routeParts","index","rP","pP","oldRouteComponent","teardown","newRouteComponent","setup","redrawing","firstChild","setRedraw","cbk","scrollTo","encodeURIComponent","join","h","h3","router","init","config","modules","preStart","postStart","/","body","Element","Promise","resolve","then","start","navigateTo","defineProperty","get","on","setRedrawing","screen","display","fn"],"mappings":";;;;;;;AAOA,MAAMA,gBAAkB,CAACC,EAAMC,KAC7B,GAAIC,OAAOC,KAAKH,GAAMI,SAAWF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,CACjCgB,IAAK,KACH,IAAKf,OACH,MAAM,IAAIjH,MAAM,4EAElB,OAAOiH,OAAO5B,SAIlBzH,OAAOmK,eAAef,GAAI,QAAS,CACjCgB,IAAK,KACH,IAAK9C,MACH,MAAM,IAAIlF,MAAM,4EAElB,OAAOkF,MAAMd,SAIjB4C,GAAGiB,GAAK,CAAClG,EAAOuC,KACd,IAAKY,MACH,MAAM,IAAIlF,MAAM,mEAElB,OAAOkF,MAAM+C,GAAGlG,EAAOuC,IAGzB0C,GAAG3C,SAAW,CAACtC,EAAOxC,KACpB,IAAK2F,MACH,MAAM,IAAIlF,MAAM,wEAElB,OAAOkF,MAAMb,SAAStC,EAAOxC,IAG/ByH,GAAG3D,OAAU6E,IACX,IAAKjB,SAAWA,OAAO5D,OACrB,MAAM,IAAIrD,MAAM,6DAEdwG,YAGJA,WAAY,EACZS,OAAO5D,SACPmD,UAAY0B,IAAgB,IAG9BlB,GAAGmB,OAAS,EAAG5B,MAAAA,EAAO6B,QAAAA,EAAS/B,SAAAA,MAC7B,IAAK+B,GAA8B,mBAAZA,EACrB,MAAM,IAAIpI,MAAM,8CAElB,GAAIuG,GAA0B,mBAAVA,EAClB,MAAM,IAAIvG,MAAM,iDAElB,GAAIqG,GAAgC,mBAAbA,EACrB,MAAM,IAAIrG,MAAM,oDAElB,MAAMqI,EAAKD,EAOX,OANI7B,IACF8B,EAAG9B,MAAQA,GAETF,IACFgC,EAAGhC,SAAWA,GAETgC,kBAGMrB","file":"h3.js"}
@@ -5,5 +5,5 @@ *
* @license MIT * For the full license, see: https://github.com/h3rald/h3/blob/master/LICENSE */ -const checkProperties=(e,t)=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e){if(!(r in t))return!1;if(!equal(e[r],t[r]))return!1}return!0},equal=(e,t)=>{if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(void 0===e&&void 0!==t||void 0!==e&&void 0===t||null===e&&null!==t||null!==e&&null===t)return!1;if(e.constructor!==t.constructor)return!1;if("function"==typeof e&&e.toString()!==t.toString())return!1;if([String,Number,Boolean].includes(e.constructor))return e===t;if(e.constructor===Array){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!equal(e[r],t[r]))return!1;return!0}return checkProperties(e,t)},selectorRegex=/^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i,[PATCH,INSERT,DELETE]=[-1,-2,-3];let $onrenderCallbacks=[];class VNode{constructor(...e){if(this.type=void 0,this.props={},this.data={},this.id=void 0,this.$html=void 0,this.$onrender=void 0,this.style=void 0,this.value=void 0,this.children=[],this.classList=[],this.eventListeners={},0===e.length)throw new Error("[VNode] No arguments passed to VNode constructor.");if(1===e.length){let t=e[0];if("string"==typeof t)this.processSelector(t);else{if("function"!=typeof t&&("object"!=typeof t||null===t))throw new Error("[VNode] Invalid first argument passed to VNode constructor.");"#text"===t.type?(this.type="#text",this.value=t.value):this.from(this.processVNodeObject(t))}}else if(2===e.length){let[t,r]=e;if("string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),"string"==typeof r)return void(this.children=[new VNode({type:"#text",value:r})]);if("function"!=typeof r&&("object"!=typeof r||null===r))throw new Error("[VNode] The second argument of a VNode constructor must be an object, an array or a string.");Array.isArray(r)||r instanceof Function||r instanceof VNode?this.processChildren(r):this.processProperties(r)}else{let[t,r,s]=e;if(e.length>3&&(s=e.slice(2)),s=Array.isArray(s)?s:[s],"string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),r instanceof Function||r instanceof VNode||"string"==typeof r)s=[r].concat(s);else{if("object"!=typeof r||null===r)throw new Error("[VNode] Invalid second argument passed to VNode constructor.");this.processProperties(r)}this.processChildren(s)}}from(e){this.value=e.value,this.type=e.type,this.id=e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.data=e.data,this.value=e.value,this.eventListeners=e.eventListeners,this.children=e.children,this.props=e.props,this.classList=e.classList}equal(e,t){return equal(e,void 0===t?this:t)}processProperties(e){this.id=this.id||e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.value=e.value,this.data=e.data||{},this.classList=e.classList&&e.classList.length>0?e.classList:this.classList,this.props=e,Object.keys(e).filter(t=>t.startsWith("on")&&e[t]).forEach(t=>{if("function"!=typeof e[t])throw new Error(`[VNode] Event handler specified for ${t} event is not a function.`);this.eventListeners[t.slice(2)]=e[t],delete this.props[t]}),delete this.props.value,delete this.props.$html,delete this.props.$onrender,delete this.props.id,delete this.props.data,delete this.props.style,delete this.props.classList}processSelector(e){if(!e.match(selectorRegex)||0===e.length)throw new Error("[VNode] Invalid selector: "+e);const[,t,r,s]=e.match(selectorRegex);this.type=t,r&&(this.id=r.slice(1)),this.classList=s&&s.split(".").slice(1)||[]}processVNodeObject(e){if(e instanceof VNode)return e;if(e instanceof Function){let t=e();if("string"==typeof t&&(t=new VNode({type:"#text",value:t})),!(t instanceof VNode))throw new Error("[VNode] Function argument does not return a VNode");return t}throw new Error("[VNode] Invalid first argument provided to VNode constructor.")}processChildren(e){const t=Array.isArray(e)?e:[e];this.children=t.map(e=>{if("string"==typeof e)return new VNode({type:"#text",value:e});if("function"==typeof e||"object"==typeof e&&null!==e)return this.processVNodeObject(e);if(e)throw new Error("[VNode] Specified child is not a VNode: "+e)}).filter(e=>e)}render(){if("#text"===this.type)return document.createTextNode(this.value);const e=document.createElement(this.type);return this.id&&(e.id=this.id),Object.keys(this.props).forEach(t=>{"boolean"==typeof this.props[t]&&(this.props[t]?e.setAttribute(t,""):e.removeAttribute(t)),["string","number"].includes(typeof this.props[t])&&e.setAttribute(t,this.props[t]),e[t]=this.props[t]}),Object.keys(this.eventListeners).forEach(t=>{e.addEventListener(t,this.eventListeners[t])}),this.value&&(["textarea","input"].includes(this.type)?e.value=this.value:e.setAttribute("value",this.value)),this.style&&(e.style.cssText=this.style),this.classList.forEach(t=>{e.classList.add(t)}),Object.keys(this.data).forEach(t=>{e.dataset[t]=this.data[t]}),this.children.forEach(t=>{const r=t.render();e.appendChild(r),t.$onrender&&$onrenderCallbacks.push(()=>t.$onrender(r))}),this.$html&&(e.innerHTML=this.$html),e}redraw(e){let{node:t,vnode:r}=e;const s=r,o=this;if(o.constructor!==s.constructor||o.type!==s.type||o.type===s.type&&"#text"===o.type&&o!==s){const e=s.render();return t.parentNode.replaceChild(e,t),s.$onrender&&s.$onrender(e),void o.from(s)}o.id!==s.id&&(t.id=s.id||"",o.id=s.id),o.value!==s.value&&(o.value=s.value,["textarea","input"].includes(o.type)?t.value=s.value||"":t.setAttribute("value",s.value||"")),equal(o.classList,s.classList)||(o.classList.forEach(e=>{s.classList.includes(e)||t.classList.remove(e)}),s.classList.forEach(e=>{o.classList.includes(e)||t.classList.add(e)}),o.classList=s.classList),o.style!==s.style&&(t.style.cssText=s.style||"",o.style=s.style),equal(o.data,s.data)||(Object.keys(o.data).forEach(e=>{s.data[e]?s.data[e]!==o.data[e]&&(t.dataset[e]=s.data[e]):delete t.dataset[e]}),Object.keys(s.data).forEach(e=>{o.data[e]||(t.dataset[e]=s.data[e])}),o.data=s.data),equal(o.props,s.props)||(Object.keys(o.props).forEach(e=>{t[e]=s.props[e],"boolean"==typeof s.props[e]?(o.props[e]=s.props[e],s.props[e]?t.setAttribute(e,""):t.removeAttribute(e)):[null,void 0].includes(s.props[e])?(delete o.props[e],t.removeAttribute(e)):s.props[e]!==o.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))}),Object.keys(s.props).forEach(e=>{!o.props[e]&&s.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))})),equal(o.eventListeners,s.eventListeners)||(Object.keys(o.eventListeners).forEach(e=>{s.eventListeners[e]?equal(s.eventListeners[e],o.eventListeners[e])||(t.removeEventListener(e,o.eventListeners[e]),t.addEventListener(e,s.eventListeners[e])):t.removeEventListener(e,o.eventListeners[e])}),Object.keys(s.eventListeners).forEach(e=>{o.eventListeners[e]||t.addEventListener(e,s.eventListeners[e])}),o.eventListeners=s.eventListeners);let i=mapChildren(o,s),n=[...Array(s.children.length).keys()];for(;!equal(i,n);){let e=-1;e:for(const r of i)if(e++,r!==e)switch(r){case PATCH:o.children[e].redraw({node:t.childNodes[e],vnode:s.children[e]});break e;case INSERT:{o.children.splice(e,0,s.children[e]);const r=s.children[e].render();t.insertBefore(r,t.childNodes[e]),s.children[e].$onrender&&s.children[e].$onrender(r);break e}case DELETE:o.children.splice(e,1),t.removeChild(t.childNodes[e]);break e;default:{const s=o.children.splice(r,1)[0];o.children.splice(e,0,s);const i=t.removeChild(t.childNodes[r]);t.insertBefore(i,t.childNodes[e]);break e}}i=mapChildren(o,s),n=[...Array(s.children.length).keys()]}equal(o.$onrender,s.$onrender)||(o.$onrender=s.$onrender),o.$html!==s.$html&&(t.innerHTML=s.$html,o.$html=s.$html,o.$onrender&&o.$onrender(t))}}const mapChildren=(e,t)=>{const r=t.children,s=e.children;let o=[];for(let e=0;e<r.length;e++){let t=PATCH;for(let i=0;i<s.length;i++)if(equal(r[e],s[i])&&!o.includes(i)){t=i;break}t<0&&r.length>=s.length&&o.length>=s.length&&(t=INSERT),o.push(t)}const i=o.filter(e=>e>=0);return s.length>r.length?[...Array(s.length-r.length).keys()].forEach(()=>o.push(DELETE)):i.length===s.length&&(o=o.map(e=>e<0?INSERT:e)),o};class Store{constructor(){this.events={},this.state={}}dispatch(e,t){if("$log"!==e&&this.dispatch("$log",{event:e,data:t}),this.events[e]){this.events[e].forEach(e=>{this.state={...this.state,...e(this.state,t)}})}}on(e,t){return(this.events[e]||(this.events[e]=[])).push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}}class Route{constructor({path:e,def:t,query:r,parts:s}){if(this.path=e,this.def=t,this.query=r,this.parts=s,this.params={},this.query){this.query.split("&").forEach(e=>{const[t,r]=e.split("=");this.params[decodeURIComponent(t)]=decodeURIComponent(r)})}}}class Router{constructor({element:e,routes:t,store:r,location:s}){if(this.element=e,this.redraw=null,this.store=r,this.location=s||window.location,!t||0===Object.keys(t).length)throw new Error("[Router] No routes defined.");Object.keys(t);this.routes=t}setRedraw(e,t){this.redraw=()=>{e.redraw({node:this.element.childNodes[0],vnode:this.routes[this.route.def](t)}),this.store.dispatch("$redraw")}}async start(){const e=async e=>{const t=this.route,r=e&&e.newURL&&e.newURL.match(/(#.+)$/)&&e.newURL.match(/(#.+)$/)[1]||this.location.hash,s=r.replace(/\?.+$/,"").slice(1),o=r.match(/\?(.+)$/),i=o&&o[1]?o[1]:"",n=s.split("/").slice(1);let a={};for(let e of Object.keys(this.routes)){let t=e.split("/").slice(1),r=!0,o=0;for(a={};r&&t[o];){const e=t[o],s=n[o];e.startsWith(":")&&s?a[e.slice(1)]=s:r=e===s,o++}if(r){this.route=new Route({query:i,path:s,def:e,parts:a});break}}if(!this.route)throw new Error(`[Router] No route matches '${r}'`);let l={};if(t){const e=this.routes[t.def];l=e.teardown&&await e.teardown(e.state)||l}const h=this.routes[this.route.def];if(h.state=l,h.setup&&!1===await h.setup(h.state))return;for(redrawing=!0,this.store.dispatch("$navigation",this.route);this.element.firstChild;)this.element.removeChild(this.element.firstChild);const c=h(h.state),d=c.render();this.element.appendChild(d),this.setRedraw(c,h.state),redrawing=!1,c.$onrender&&c.$onrender(d),$onrenderCallbacks.forEach(e=>e()),$onrenderCallbacks=[],window.scrollTo(0,0),this.store.dispatch("$redraw")};window.addEventListener("hashchange",e),await e()}navigateTo(e,t){let r=Object.keys(t||{}).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&");r=r?"?"+r:"",this.location.hash=`#${e}${r}`}}export const h=(...e)=>new VNode(...e);export const h3={};let store=null,router=null,redrawing=!1;h3.init=e=>{let{element:t,routes:r,modules:s,preStart:o,postStart:i,location:n}=e;if(!r){if("function"!=typeof e)throw new Error("[h3.init] The specified argument is not a valid configuration object or component function");r={"/":e}}if(t=t||document.body,!(t&&t instanceof Element))throw new Error("[h3.init] Invalid element specified.");return store=new Store,(s||[]).forEach(e=>{e(store)}),store.dispatch("$init"),router=new Router({element:t,routes:r,store:store,location:n}),Promise.resolve(o&&o()).then(()=>router.start()).then(()=>i&&i())},h3.navigateTo=(e,t)=>{if(!router)throw new Error("[h3.navigateTo] No application initialized, unable to navigate.");return router.navigateTo(e,t)},Object.defineProperty(h3,"route",{get:()=>{if(!router)throw new Error("[h3.route] No application initialized, unable to retrieve current route.");return router.route}}),Object.defineProperty(h3,"state",{get:()=>{if(!store)throw new Error("[h3.state] No application initialized, unable to retrieve current state.");return store.state}}),h3.on=(e,t)=>{if(!store)throw new Error("[h3.on] No application initialized, unable to listen to events.");return store.on(e,t)},h3.dispatch=(e,t)=>{if(!store)throw new Error("[h3.dispatch] No application initialized, unable to dispatch events.");return store.dispatch(e,t)},h3.redraw=e=>{if(!router||!router.redraw)throw new Error("[h3.redraw] No application initialized, unable to redraw.");redrawing||(redrawing=!0,router.redraw(),redrawing=e||!1)},h3.screen=({setup:e,display:t,teardown:r})=>{if(!t||"function"!=typeof t)throw new Error("[h3.screen] No display property specified.");if(e&&"function"!=typeof e)throw new Error("[h3.screen] setup property is not a function.");if(r&&"function"!=typeof r)throw new Error("[h3.screen] teardown property is not a function.");const s=t;return e&&(s.setup=e),r&&(s.teardown=r),s};export default h3; +const checkProperties=(e,t)=>{if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e){if(!(r in t))return!1;if(!equal(e[r],t[r]))return!1}return!0},blank=e=>[void 0,null].includes(e),equal=(e,t)=>{if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(void 0===e&&void 0!==t||void 0!==e&&void 0===t||null===e&&null!==t||null!==e&&null===t)return!1;if(e.constructor!==t.constructor)return!1;if("function"==typeof e&&e.toString()!==t.toString())return!1;if([String,Number,Boolean].includes(e.constructor))return e===t;if(e.constructor===Array){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!equal(e[r],t[r]))return!1;return!0}return checkProperties(e,t)},selectorRegex=/^([a-z][a-z0-9:_=-]*)?(#[a-z0-9:_=-]+)?(\.[^ ]+)*$/i,[PATCH,INSERT,DELETE]=[-1,-2,-3];let $onrenderCallbacks=[];class VNode{constructor(...e){if(this.type=void 0,this.props={},this.data={},this.id=void 0,this.$html=void 0,this.$onrender=void 0,this.style=void 0,this.value=void 0,this.children=[],this.classList=[],this.eventListeners={},0===e.length)throw new Error("[VNode] No arguments passed to VNode constructor.");if(1===e.length){let t=e[0];if("string"==typeof t)this.processSelector(t);else{if("function"!=typeof t&&("object"!=typeof t||null===t))throw new Error("[VNode] Invalid first argument passed to VNode constructor.");"#text"===t.type?(this.type="#text",this.value=t.value):this.from(this.processVNodeObject(t))}}else if(2===e.length){let[t,r]=e;if("string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),"string"==typeof r)return void(this.children=[new VNode({type:"#text",value:r})]);if("function"!=typeof r&&("object"!=typeof r||null===r))throw new Error("[VNode] The second argument of a VNode constructor must be an object, an array or a string.");Array.isArray(r)||r instanceof Function||r instanceof VNode?this.processChildren(r):this.processProperties(r)}else{let[t,r,s]=e;if(e.length>3&&(s=e.slice(2)),s=Array.isArray(s)?s:[s],"string"!=typeof t)throw new Error("[VNode] Invalid first argument passed to VNode constructor.");if(this.processSelector(t),r instanceof Function||r instanceof VNode||"string"==typeof r)s=[r].concat(s);else{if("object"!=typeof r||null===r)throw new Error("[VNode] Invalid second argument passed to VNode constructor.");this.processProperties(r)}this.processChildren(s)}}from(e){this.value=e.value,this.type=e.type,this.id=e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.data=e.data,this.value=e.value,this.eventListeners=e.eventListeners,this.children=e.children,this.props=e.props,this.classList=e.classList}equal(e,t){return equal(e,void 0===t?this:t)}processProperties(e){this.id=this.id||e.id,this.$html=e.$html,this.$onrender=e.$onrender,this.style=e.style,this.value=e.value,this.data=e.data||{},this.classList=e.classList&&e.classList.length>0?e.classList:this.classList,this.props=e,Object.keys(e).filter(t=>t.startsWith("on")&&e[t]).forEach(t=>{if("function"!=typeof e[t])throw new Error(`[VNode] Event handler specified for ${t} event is not a function.`);this.eventListeners[t.slice(2)]=e[t],delete this.props[t]}),delete this.props.value,delete this.props.$html,delete this.props.$onrender,delete this.props.id,delete this.props.data,delete this.props.style,delete this.props.classList}processSelector(e){if(!e.match(selectorRegex)||0===e.length)throw new Error("[VNode] Invalid selector: "+e);const[,t,r,s]=e.match(selectorRegex);this.type=t,r&&(this.id=r.slice(1)),this.classList=s&&s.split(".").slice(1)||[]}processVNodeObject(e){if(e instanceof VNode)return e;if(e instanceof Function){let t=e();if("string"==typeof t&&(t=new VNode({type:"#text",value:t})),!(t instanceof VNode))throw new Error("[VNode] Function argument does not return a VNode");return t}throw new Error("[VNode] Invalid first argument provided to VNode constructor.")}processChildren(e){const t=Array.isArray(e)?e:[e];this.children=t.map(e=>{if("string"==typeof e)return new VNode({type:"#text",value:e});if("function"==typeof e||"object"==typeof e&&null!==e)return this.processVNodeObject(e);if(e)throw new Error("[VNode] Specified child is not a VNode: "+e)}).filter(e=>e)}render(){if("#text"===this.type)return document.createTextNode(this.value);const e=document.createElement(this.type);return blank(this.id)||(e.id=this.id),Object.keys(this.props).forEach(t=>{"boolean"==typeof this.props[t]&&(this.props[t]?e.setAttribute(t,""):e.removeAttribute(t)),["string","number"].includes(typeof this.props[t])&&e.setAttribute(t,this.props[t]),e[t]=this.props[t]}),Object.keys(this.eventListeners).forEach(t=>{e.addEventListener(t,this.eventListeners[t])}),this.value&&(["textarea","input","option","button"].includes(this.type)?e.value=this.value:e.setAttribute("value",this.value.toString())),this.style&&(e.style.cssText=this.style),this.classList.forEach(t=>{t&&e.classList.add(t)}),Object.keys(this.data).forEach(t=>{e.dataset[t]=this.data[t]}),this.children.forEach(t=>{const r=t.render();e.appendChild(r),t.$onrender&&$onrenderCallbacks.push(()=>t.$onrender(r))}),this.$html&&(e.innerHTML=this.$html),e}redraw(e){let{node:t,vnode:r}=e;const s=r,o=this;if(o.constructor!==s.constructor||o.type!==s.type||o.type===s.type&&"#text"===o.type&&o!==s){const e=s.render();return t.parentNode.replaceChild(e,t),s.$onrender&&s.$onrender(e),void o.from(s)}o.id!==s.id&&(t.id=s.id,o.id=s.id),o.value!==s.value&&(o.value=s.value,["textarea","input","option","button"].includes(o.type)?t.value=blank(s.value)?"":s.value.toString():t.setAttribute("value",blank(s.value)?"":s.value.toString())),equal(o.classList,s.classList)||(o.classList.forEach(e=>{s.classList.includes(e)||t.classList.remove(e)}),s.classList.forEach(e=>{e&&!o.classList.includes(e)&&t.classList.add(e)}),o.classList=s.classList),o.style!==s.style&&(t.style.cssText=s.style||"",o.style=s.style),equal(o.data,s.data)||(Object.keys(o.data).forEach(e=>{s.data[e]?s.data[e]!==o.data[e]&&(t.dataset[e]=s.data[e]):delete t.dataset[e]}),Object.keys(s.data).forEach(e=>{o.data[e]||(t.dataset[e]=s.data[e])}),o.data=s.data),equal(o.props,s.props)||(Object.keys(o.props).forEach(e=>{t[e]=s.props[e],"boolean"==typeof s.props[e]?(o.props[e]=s.props[e],s.props[e]?t.setAttribute(e,""):t.removeAttribute(e)):[null,void 0].includes(s.props[e])?(delete o.props[e],t.removeAttribute(e)):s.props[e]!==o.props[e]&&(o.props[e]=s.props[e],["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))}),Object.keys(s.props).forEach(e=>{blank(o.props[e])&&!blank(s.props[e])&&(o.props[e]=s.props[e],t[e]=s.props[e],"boolean"==typeof s.props[e]?t.setAttribute(e,""):["string","number"].includes(typeof s.props[e])&&t.setAttribute(e,s.props[e]))})),equal(o.eventListeners,s.eventListeners)||(Object.keys(o.eventListeners).forEach(e=>{s.eventListeners[e]?equal(s.eventListeners[e],o.eventListeners[e])||(t.removeEventListener(e,o.eventListeners[e]),t.addEventListener(e,s.eventListeners[e])):t.removeEventListener(e,o.eventListeners[e])}),Object.keys(s.eventListeners).forEach(e=>{o.eventListeners[e]||t.addEventListener(e,s.eventListeners[e])}),o.eventListeners=s.eventListeners);let i=mapChildren(o,s),n=[...Array(s.children.length).keys()];for(;!equal(i,n);){let e=-1;e:for(const r of i)if(e++,r!==e)switch(r){case PATCH:o.children[e].redraw({node:t.childNodes[e],vnode:s.children[e]});break e;case INSERT:{o.children.splice(e,0,s.children[e]);const r=s.children[e].render();t.insertBefore(r,t.childNodes[e]),s.children[e].$onrender&&s.children[e].$onrender(r);break e}case DELETE:o.children.splice(e,1),t.removeChild(t.childNodes[e]);break e;default:{const s=o.children.splice(r,1)[0];o.children.splice(e,0,s);const i=t.removeChild(t.childNodes[r]);t.insertBefore(i,t.childNodes[e]);break e}}i=mapChildren(o,s),n=[...Array(s.children.length).keys()]}equal(o.$onrender,s.$onrender)||(o.$onrender=s.$onrender),o.$html!==s.$html&&(t.innerHTML=s.$html,o.$html=s.$html,o.$onrender&&o.$onrender(t))}}const mapChildren=(e,t)=>{const r=t.children,s=e.children;let o=[];for(let e=0;e<r.length;e++){let t=PATCH;for(let i=0;i<s.length;i++)if(equal(r[e],s[i])&&!o.includes(i)){t=i;break}t<0&&r.length>=s.length&&o.length>=s.length&&(t=INSERT),o.push(t)}const i=o.filter(e=>e>=0);return s.length>r.length?[...Array(s.length-r.length).keys()].forEach(()=>o.push(DELETE)):i.length===s.length&&(o=o.map(e=>e<0?INSERT:e)),o};class Store{constructor(){this.events={},this.state={}}dispatch(e,t){if("$log"!==e&&this.dispatch("$log",{event:e,data:t}),this.events[e]){this.events[e].forEach(e=>{this.state={...this.state,...e(this.state,t)}})}}on(e,t){return(this.events[e]||(this.events[e]=[])).push(t),()=>{this.events[e]=this.events[e].filter(e=>e!==t)}}}class Route{constructor({path:e,def:t,query:r,parts:s}){if(this.path=e,this.def=t,this.query=r,this.parts=s,this.params={},this.query){this.query.split("&").forEach(e=>{const[t,r]=e.split("=");this.params[decodeURIComponent(t)]=decodeURIComponent(r)})}}}class Router{constructor({element:e,routes:t,store:r,location:s}){if(this.element=e,this.redraw=null,this.store=r,this.location=s||window.location,!t||0===Object.keys(t).length)throw new Error("[Router] No routes defined.");Object.keys(t);this.routes=t}setRedraw(e,t){this.redraw=()=>{e.redraw({node:this.element.childNodes[0],vnode:this.routes[this.route.def](t)}),this.store.dispatch("$redraw")}}async start(){const e=async e=>{const t=this.route,r=e&&e.newURL&&e.newURL.match(/(#.+)$/)&&e.newURL.match(/(#.+)$/)[1]||this.location.hash,s=r.replace(/\?.+$/,"").slice(1),o=r.match(/\?(.+)$/),i=o&&o[1]?o[1]:"",n=s.split("/").slice(1);let a,l={};for(let e of Object.keys(this.routes)){let t=e.split("/").slice(1),r=!0,o=0;for(l={};r&&t[o];){const e=t[o],s=n[o];e.startsWith(":")&&s?l[e.slice(1)]=s:r=e===s,o++}if(r){a=new Route({query:i,path:s,def:e,parts:l});break}}if(!a)throw new Error(`[Router] No route matches '${r}'`);let h={};if(t){const e=this.routes[t.def];h=e.teardown&&await e.teardown(e.state)||h}const d=this.routes[a.def];if(d.state=h,d.setup&&!1===await d.setup(d.state))return;for(this.route=a,redrawing=!0,this.store.dispatch("$navigation",this.route);this.element.firstChild;)this.element.removeChild(this.element.firstChild);const c=d(d.state),p=c.render();this.element.appendChild(p),this.setRedraw(c,d.state),redrawing=!1,c.$onrender&&c.$onrender(p),$onrenderCallbacks.forEach(e=>e()),$onrenderCallbacks=[],window.scrollTo(0,0),this.store.dispatch("$redraw")};window.addEventListener("hashchange",e),await e()}navigateTo(e,t){let r=Object.keys(t||{}).map(e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`).join("&");r=r?"?"+r:"",this.location.hash=`#${e}${r}`}}export const h=(...e)=>new VNode(...e);export const h3={};let store=null,router=null,redrawing=!1;h3.init=e=>{let{element:t,routes:r,modules:s,preStart:o,postStart:i,location:n}=e;if(!r){if("function"!=typeof e)throw new Error("[h3.init] The specified argument is not a valid configuration object or component function");r={"/":e}}if(t=t||document.body,!(t&&t instanceof Element))throw new Error("[h3.init] Invalid element specified.");return store=new Store,(s||[]).forEach(e=>{e(store)}),store.dispatch("$init"),router=new Router({element:t,routes:r,store:store,location:n}),Promise.resolve(o&&o()).then(()=>router.start()).then(()=>i&&i())},h3.navigateTo=(e,t)=>{if(!router)throw new Error("[h3.navigateTo] No application initialized, unable to navigate.");return router.navigateTo(e,t)},Object.defineProperty(h3,"route",{get:()=>{if(!router)throw new Error("[h3.route] No application initialized, unable to retrieve current route.");return router.route}}),Object.defineProperty(h3,"state",{get:()=>{if(!store)throw new Error("[h3.state] No application initialized, unable to retrieve current state.");return store.state}}),h3.on=(e,t)=>{if(!store)throw new Error("[h3.on] No application initialized, unable to listen to events.");return store.on(e,t)},h3.dispatch=(e,t)=>{if(!store)throw new Error("[h3.dispatch] No application initialized, unable to dispatch events.");return store.dispatch(e,t)},h3.redraw=e=>{if(!router||!router.redraw)throw new Error("[h3.redraw] No application initialized, unable to redraw.");redrawing||(redrawing=!0,router.redraw(),redrawing=e||!1)},h3.screen=({setup:e,display:t,teardown:r})=>{if(!t||"function"!=typeof t)throw new Error("[h3.screen] No display property specified.");if(e&&"function"!=typeof e)throw new Error("[h3.screen] setup property is not a function.");if(r&&"function"!=typeof r)throw new Error("[h3.screen] teardown property is not a function.");const s=t;return e&&(s.setup=e),r&&(s.teardown=r),s};export default h3; //# sourceMappingURL=h3.js.map