From bc0a75a6a20f1cbefe0c58b7b2f1687f34a7746d Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 2 Nov 2016 15:38:23 -0400 Subject: [PATCH] fix regression when empty text node --- mithril.js | 18 ++++++++++-------- mithril.min.js | 4 ++-- render/render.js | 18 ++++++++++-------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/mithril.js b/mithril.js index 67dd7173..a80552fb 100644 --- a/mithril.js +++ b/mithril.js @@ -502,14 +502,16 @@ var _14 = function($window) { if (vnode.attrs != null && vnode.attrs.contenteditable != null) { setContentEditable(vnode) } - else if (vnode.text != null) { - if (vnode.text !== "") element.textContent = vnode.text - else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] - } - else if (vnode.children != null) { - var children = vnode.children - createNodes(element, children, 0, children.length, hooks, null, ns) - setLateAttrs(vnode) + else { + if (vnode.text != null) { + if (vnode.text !== "") element.textContent = vnode.text + else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] + } + if (vnode.children != null) { + var children = vnode.children + createNodes(element, children, 0, children.length, hooks, null, ns) + setLateAttrs(vnode) + } } return element } diff --git a/mithril.min.js b/mithril.min.js index 67cb1887..71c9a814 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -16,8 +16,8 @@ x.open(e.method,e.url,"boolean"===typeof e.async?e.async:!0,"string"===typeof e. x.status&&300>x.status||304===x.status)l(y(e.type,c));else{var f=Error(x.responseText),g;for(g in c)f[g]=c[g];l.error(f)}}catch(T){l.error(T)}"function"===typeof n&&n()}};r?x.send(e.data):x.send();return l},jsonp:function(e){var l=f();void 0!==e.initialValue&&l(e.initialValue);var h=e.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+z++,k=c.document.createElement("script");c[h]=function(f){k.parentNode.removeChild(k);l(y(e.type,f));"function"===typeof n&&n();delete c[h]};k.onerror=function(){k.parentNode.removeChild(k); l.error(Error("JSONP request failed"));"function"===typeof n&&n();delete c[h]};null==e.data&&(e.data={});e.url=p(e.url,e.data);e.data[e.callbackKey||"callback"]=h;k.src=g(e.url,e.data);c.document.documentElement.appendChild(k);return l},setCompletionCallback:function(c){n=c}}}(window,P),M=function(){var c=[];return{subscribe:c.push.bind(c),unsubscribe:function(f){f=c.indexOf(f);-1=k&&w>=A;){var t=a[k],u=d[A];if(t!==u||m)if(null!=t&&null!=u&&t.key===u.key)k++,A++,h(b,t,u,c,z(a,k,e),m,g),m&&t.tag===u.tag&&n(b,y(t),e);else if(t=a[r],t!==u||m)if(null!=t&&null!=u&&t.key===u.key)h(b,t,u,c,z(a,r+1,e),m,g),(m||A=k&&w>=A;){t=a[r];u=d[w];if(t!==u||m)if(null!=t&&null!=u&&t.key=== diff --git a/render/render.js b/render/render.js index 7452f8c6..fa4bbed1 100644 --- a/render/render.js +++ b/render/render.js @@ -81,14 +81,16 @@ module.exports = function($window) { if (vnode.attrs != null && vnode.attrs.contenteditable != null) { setContentEditable(vnode) } - else if (vnode.text != null) { - if (vnode.text !== "") element.textContent = vnode.text - else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] - } - else if (vnode.children != null) { - var children = vnode.children - createNodes(element, children, 0, children.length, hooks, null, ns) - setLateAttrs(vnode) + else { + if (vnode.text != null) { + if (vnode.text !== "") element.textContent = vnode.text + else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] + } + if (vnode.children != null) { + var children = vnode.children + createNodes(element, children, 0, children.length, hooks, null, ns) + setLateAttrs(vnode) + } } return element }