From 2b856ed6ac34cfbeb8d1fdbe6299d067d6a9123d Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 23 Nov 2016 23:33:57 -0500 Subject: [PATCH] remove unnecessary append --- README.md | 2 +- mithril.js | 8 ++--- mithril.min.js | 80 ++++++++++++++++++++++++------------------------ render/render.js | 9 +++--- 4 files changed, 49 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index 71c22280..f748cef7 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,6 @@ There are over 4000 assertions in the test suite, and tests cover even difficult ## Modularity -Despite the huge improvements in performance and modularity, the new codebase is smaller than v0.2.x, currently clocking at 7.41 KB min+gzip +Despite the huge improvements in performance and modularity, the new codebase is smaller than v0.2.x, currently clocking at 7.40 KB min+gzip In addition, Mithril is now completely modular: you can import only the modules that you need and easily integrate 3rd party modules if you wish to use a different library for routing, ajax, and even rendering diff --git a/mithril.js b/mithril.js index 025d9f78..7fdbec3a 100644 --- a/mithril.js +++ b/mithril.js @@ -456,18 +456,18 @@ var _13 = function($window) { else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined) else if (vnodes == null) removeNodes(old, 0, old.length, vnodes) else { - var recycling = isRecyclable(old, vnodes) - if (recycling) old = old.concat(old.pool) if (old.length === vnodes.length && vnodes[0] != null && vnodes[0].key == null) { for (var i = 0; i < old.length; i++) { if (old[i] === vnodes[i] || old[i] == null && vnodes[i] == null) continue else if (old[i] == null) insertNode(parent, createNode(vnodes[i], hooks, ns), getNextSibling(old, i + 1, nextSibling)) else if (vnodes[i] == null) removeNodes(old, i, i + 1, vnodes) - else updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), recycling, ns) - if (recycling && old[i].tag === vnodes[i].tag) insertNode(parent, toFragment(old[i]), getNextSibling(old, i + 1, nextSibling)) + else updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), false, ns) } } else { + var recycling = isRecyclable(old, vnodes) + if (recycling) old = old.concat(old.pool) + var oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map while (oldEnd >= oldStart && end >= start) { var o = old[oldStart], v = vnodes[start] diff --git a/mithril.min.js b/mithril.min.js index bdf1bb88..41590c4a 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,40 +1,40 @@ -new function(){function m(a,b,k,d,l,h){return{tag:a,key:b,attrs:k,children:d,text:l,dom:h,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function t(a){if(null==a||"string"!==typeof a&&null==a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===G[a]){for(var b,k,d=[],l={};b=N.exec(a);){var h=b[1],w=b[2];""===h&&""!==w?k=w:"#"===h?l.id=w:"."===h?d.push(w):"["===b[3][0]&&((h=b[6])&&(h=h.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")), -"class"===b[4]?d.push(h):l[b[4]]=h||!0)}0a.indexOf("?")?"?":"&";a+=d+f}return a}function w(a){try{return""!== -a?JSON.parse(a):null}catch(x){throw Error(a);}}function p(a){return a.responseText}function r(a,b){if("function"===typeof a)if(b instanceof Array)for(var d=0;dn.status||304===n.status)b(r(f.type,a));else{var h=Error(n.responseText),k;for(k in a)h[k]=a[k];d(h)}}catch(F){d(F)}}; -q&&null!=f.data?n.send(f.data):n.send()}))},jsonp:function(f){return d(new b(function(b,d){var n=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,k=a.document.createElement("script");a[n]=function(d){k.parentNode.removeChild(k);b(r(f.type,d));delete a[n]};k.onerror=function(){k.parentNode.removeChild(k);d(Error("JSONP request failed"));delete a[n]};null==f.data&&(f.data={});f.url=l(f.url,f.data);f.data[f.callbackKey||"callback"]=n;k.src=h(f.url,f.data);a.document.documentElement.appendChild(k)}))}, -setCompletionCallback:function(a){u=a}}}(window,"undefined"!==typeof Promise?Promise:z),I=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1=v&&B>=l;){var y=a[v],m=e[l];if(y!==m||g)if(null==y)v++;else if(null==m)l++;else if(y.key===m.key)v++,l++, -h(c,y,m,f,p(a,v,d),g,n),g&&y.tag===m.tag&&r(c,w(y),d);else if(y=a[u],y!==m||g)if(null==y)u--;else if(null==m)l++;else if(y.key===m.key)h(c,y,m,f,p(a,u+1,d),g,n),(g||l=v&&B>=l;){y=a[u];m=e[B];if(y!==m||g)if(null==y)u--;else{if(null!=m)if(y.key===m.key)h(c,y,m,f,p(a,u+1,d),g,n),g&&y.tag===m.tag&&r(c,w(y),d),null!=y.dom&&(d=y.dom),u--;else{if(!x){x=a;var y=u,D={},A;for(A=0;Aa.indexOf("?")?"?":"&";a+=e+f}return a}function v(a){try{return""!== +a?JSON.parse(a):null}catch(w){throw Error(a);}}function p(a){return a.responseText}function r(a,b){if("function"===typeof a)if(b instanceof Array)for(var e=0;en.status||304===n.status)b(r(f.type,a));else{var h=Error(n.responseText),k;for(k in a)h[k]=a[k];e(h)}}catch(G){e(G)}}; +u&&null!=f.data?n.send(f.data):n.send()}))},jsonp:function(f){return e(new b(function(b,e){var n=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,k=a.document.createElement("script");a[n]=function(e){k.parentNode.removeChild(k);b(r(f.type,e));delete a[n]};k.onerror=function(){k.parentNode.removeChild(k);e(Error("JSONP request failed"));delete a[n]};null==f.data&&(f.data={});f.url=l(f.url,f.data);f.data[f.callbackKey||"callback"]=n;k.src=h(f.url,f.data);a.document.documentElement.appendChild(k)}))}, +setCompletionCallback:function(a){q=a}}}(window,"undefined"!==typeof Promise?Promise:y),J=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1=A&&B>=l;){var x=a[A],m=d[l];if(x!==m||g)if(null==x)A++;else if(null==m)l++;else if(x.key===m.key)A++,l++,h(c,x,m,f,p(a,A,e),g,n),g&&x.tag===m.tag&&r(c,v(x),e); +else if(x=a[q],x!==m||g)if(null==x)q--;else if(null==m)l++;else if(x.key===m.key)h(c,x,m,f,p(a,q+1,e),g,n),(g||l=A&&B>=l;){x=a[q];m=d[B];if(x!==m||g)if(null==x)q--;else{if(null!=m)if(x.key===m.key)h(c,x,m,f,p(a,q+1,e),g,n),g&&x.tag===m.tag&&r(c,v(x),e),null!=x.dom&&(e=x.dom),q--;else{if(!w){w=a;var x=q,D={},z;for(z=0;z= oldStart && end >= start) { var o = old[oldStart], v = vnodes[start]