all repos — h3 @ 7fdd6f2ef96d65e05c5a9b3b5ad30bbad83f423a

A tiny, extremely minimalist JavaScript microframework.

Fixed innerHTML redrawing.
h3rald h3rald@h3rald.com
Sat, 18 Apr 2020 15:05:52 +0200
commit

7fdd6f2ef96d65e05c5a9b3b5ad30bbad83f423a

parent

4b9f458e76b5dc8ac68cb42f7e2f0e959807b2db

3 files changed, 27 insertions(+), 30 deletions(-)

jump to
M docs/js/h3.jsdocs/js/h3.js

@@ -141,14 +141,13 @@ throw new Error(`[VNode] Specified child is not a VNode: ${c}`);

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

@@ -188,7 +187,7 @@ if (typeof data === "string") {

// Assume single child text node this.type = "#text"; this.value = data; - return + return; } if (typeof data !== "object" || data === null) { throw new Error(

@@ -378,11 +377,6 @@ node.addEventListener(a, newvnode.eventListeners[a]);

} }); oldvnode.eventListeners = newvnode.eventListeners; - } - // innerHTML - if (oldvnode.$html !== newvnode.$html) { - node.innerHTML = newvnode.$html; - oldvnode.$html = newvnode.$html; } // Children var newmap = []; // Map positions of newvnode children in relation to oldvnode children

@@ -458,6 +452,11 @@ }

} } } + // innerHTML + if (oldvnode.$html !== newvnode.$html) { + node.innerHTML = newvnode.$html; + oldvnode.$html = newvnode.$html; + } } }

@@ -577,7 +576,7 @@ // Display View

while (this.element.firstChild) { this.element.removeChild(this.element.firstChild); } - const vnode = this.routes[this.route.def]() + const vnode = this.routes[this.route.def](); this.element.appendChild(vnode.render()); this.setRedraw(vnode); this.store.dispatch("$navigation", this.route);

@@ -617,7 +616,7 @@ // Initialize router

router = new Router({ element, routes, store }); return Promise.resolve(preStart && preStart()) .then(() => router.start()) - .then(() => postStart && postStart()) + .then(() => postStart && postStart()); }; h3.navigateTo = (path, params) => {
M example/assets/js/h3.jsexample/assets/js/h3.js

@@ -141,14 +141,13 @@ throw new Error(`[VNode] Specified child is not a VNode: ${c}`);

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

@@ -188,7 +187,7 @@ if (typeof data === "string") {

// Assume single child text node this.type = "#text"; this.value = data; - return + return; } if (typeof data !== "object" || data === null) { throw new Error(

@@ -378,11 +377,6 @@ node.addEventListener(a, newvnode.eventListeners[a]);

} }); oldvnode.eventListeners = newvnode.eventListeners; - } - // innerHTML - if (oldvnode.$html !== newvnode.$html) { - node.innerHTML = newvnode.$html; - oldvnode.$html = newvnode.$html; } // Children var newmap = []; // Map positions of newvnode children in relation to oldvnode children

@@ -458,6 +452,11 @@ }

} } } + // innerHTML + if (oldvnode.$html !== newvnode.$html) { + node.innerHTML = newvnode.$html; + oldvnode.$html = newvnode.$html; + } } }

@@ -577,7 +576,7 @@ // Display View

while (this.element.firstChild) { this.element.removeChild(this.element.firstChild); } - const vnode = this.routes[this.route.def]() + const vnode = this.routes[this.route.def](); this.element.appendChild(vnode.render()); this.setRedraw(vnode); this.store.dispatch("$navigation", this.route);

@@ -617,7 +616,7 @@ // Initialize router

router = new Router({ element, routes, store }); return Promise.resolve(preStart && preStart()) .then(() => router.start()) - .then(() => postStart && postStart()) + .then(() => postStart && postStart()); }; h3.navigateTo = (path, params) => {
M h3.jsh3.js

@@ -141,14 +141,13 @@ throw new Error(`[VNode] Specified child is not a VNode: ${c}`);

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

@@ -188,7 +187,7 @@ if (typeof data === "string") {

// Assume single child text node this.type = "#text"; this.value = data; - return + return; } if (typeof data !== "object" || data === null) { throw new Error(

@@ -378,11 +377,6 @@ node.addEventListener(a, newvnode.eventListeners[a]);

} }); oldvnode.eventListeners = newvnode.eventListeners; - } - // innerHTML - if (oldvnode.$html !== newvnode.$html) { - node.innerHTML = newvnode.$html; - oldvnode.$html = newvnode.$html; } // Children var newmap = []; // Map positions of newvnode children in relation to oldvnode children

@@ -458,6 +452,11 @@ }

} } } + // innerHTML + if (oldvnode.$html !== newvnode.$html) { + node.innerHTML = newvnode.$html; + oldvnode.$html = newvnode.$html; + } } }

@@ -577,7 +576,7 @@ // Display View

while (this.element.firstChild) { this.element.removeChild(this.element.firstChild); } - const vnode = this.routes[this.route.def]() + const vnode = this.routes[this.route.def](); this.element.appendChild(vnode.render()); this.setRedraw(vnode); this.store.dispatch("$navigation", this.route);

@@ -617,7 +616,7 @@ // Initialize router

router = new Router({ element, routes, store }); return Promise.resolve(preStart && preStart()) .then(() => router.start()) - .then(() => postStart && postStart()) + .then(() => postStart && postStart()); }; h3.navigateTo = (path, params) => {