From efae454bd44daedf14940f8d73fb10aef7d7ed16 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Thu, 3 Apr 2014 09:00:47 -0400 Subject: [PATCH] improve dom caching - don't call appendChild if not needed - don't overwrite style all the time - don't overwrite function if it has same source --- archive/v0.1.3/mithril-tests.js | 24 ++++++++++++++++-------- archive/v0.1.3/mithril.min.js | 2 +- archive/v0.1.3/mithril.min.map | 2 +- archive/v0.1.3/mithril.min.zip | Bin 20403 -> 20592 bytes mithril.js | 23 +++++++++++++++-------- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/archive/v0.1.3/mithril-tests.js b/archive/v0.1.3/mithril-tests.js index de1dfeed..e40e1676 100644 --- a/archive/v0.1.3/mithril-tests.js +++ b/archive/v0.1.3/mithril-tests.js @@ -73,7 +73,7 @@ new function(window) { setAttributes(node, data.attrs, cached.attrs) cached.children = build(node, data.children, cached.children) cached.nodes.intact = true - parent.appendChild(node) + if (node.parentNode !== parent) parent.appendChild(node) } if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew) } @@ -120,13 +120,20 @@ new function(window) { function setAttributes(node, dataAttrs, cachedAttrs) { for (var attrName in dataAttrs) { var dataAttr = dataAttrs[attrName] - if (!(attrName in cachedAttrs) || (cachedAttrs[attrName] !== dataAttr) || node === window.document.activeElement) { - cachedAttrs[attrName] = dataAttr - if (attrName == "config") continue - if (attrName.indexOf("on") == 0 && typeof dataAttr == "function") dataAttr = autoredraw(dataAttr, node) - if (attrName == "style") for (var rule in dataAttr) node.style[rule] = dataAttr[rule] + var cachedAttr = cachedAttrs[attrName] + if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) { + if (attrName === "config") continue + else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) { + if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node) + } + else if (attrName === "style") { + for (var rule in dataAttr) { + if (cachedAttr === undefined || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] + } + } else if (attrName in node) node[attrName] = dataAttr else node.setAttribute(attrName, dataAttr) + cachedAttrs[attrName] = dataAttr } } return cachedAttrs @@ -141,9 +148,9 @@ new function(window) { return result } function autoredraw(callback, object) { - return function() { + return function(e) { m.startComputation() - var output = callback.apply(object || window, arguments) + var output = callback.call(object, e) m.endComputation() return output } @@ -460,6 +467,7 @@ mock.window = new function() { getAttribute: function(name, value) { return this[name] }, + style: {} } } window.document.createTextNode = function(text) { diff --git a/archive/v0.1.3/mithril.min.js b/archive/v0.1.3/mithril.min.js index 0cba8242..ba474595 100644 --- a/archive/v0.1.3/mithril.min.js +++ b/archive/v0.1.3/mithril.min.js @@ -4,5 +4,5 @@ http://github.com/lhorie/mithril.js (c) Leo Horie License: MIT */ -!new function(a){function b(e,f,g){if(null!==f&&void 0!==f){var h=s.call(g),i=s.call(f);if(h!=i&&(null!==g&&void 0!==g&&d(g.nodes),g=new f.constructor,g.nodes=[]),"[object Array]"==i){for(var j=[],k=g.length===f.length,l=0;l-1?new f.constructor(f):f,g.nodes=[n]}else if(g.valueOf()!==f.valueOf()){if(f.$trusted){var q=g.nodes[0],j=[q];if(q){for(;q=q.nextSibling;)j.push(q);d(j);var p=e.lastChild;e.insertAdjacentHTML("beforeend",f),n=p?p.nextSibling:e.firstChild}else e.innerHTML=f}else n=g.nodes[0],e.appendChild(n),n.nodeValue=f;g=new f.constructor(f),g.nodes=[n]}else g.nodes.intact=!0}return g}}function c(b,c,d){for(var e in c){var g=c[e];if(!(e in d)||d[e]!==g||b===a.document.activeElement){if(d[e]=g,"config"==e)continue;if(0==e.indexOf("on")&&"function"==typeof g&&(g=f(g,b)),"style"==e)for(var h in g)b.style[h]=g[h];else e in b?b[e]=g:b.setAttribute(e,g)}}return d}function d(a){for(var b=0;b16)m.redraw();else{var b=a.cancelAnimationFrame||a.clearTimeout,c=a.requestAnimationFrame||a.setTimeout;b(E),E=c(m.redraw,0)}}function h(a,b,c){J={};for(var d in b){if(d==c)return!void m.module(a,b[d]);var e=new RegExp("^"+d.replace(/:[^\/]+/g,"([^\\/]+)")+"$");if(e.test(c))return!void c.replace(e,function(){for(var c=d.match(/:[^\/]+/g),e=[].slice.call(arguments,1,-2),f=0;f0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+n(b):a.data=c(b)),a}function p(a,b){var c=a.match(/:\w+/g);if(c&&b)for(var d=0;d0&&(f.attrs[d]=h.join(" "))}f=e(f),f.attrs=e(f.attrs),f.children=b?a[2]:a[1];for(var j in c)f.attrs[j]=j==d?(f.attrs[j]||"")+" "+c[j]:c[j];return f};var v,w={insertAdjacentHTML:function(b,c){a.document.write(c),a.document.close()},appendChild:function(b){void 0===v&&(v=a.document.createElement("html")),"HTML"==b.nodeName?v=b:v.appendChild(b),a.document.documentElement!==v&&a.document.replaceChild(v,a.document.documentElement)}},x=[],y={};m.render=function(c,d){var e=x.indexOf(c),f=0>e?x.push(c)-1:e,g=c==a.document||c==a.document.documentElement?w:c;y[f]=b(g,d,y[f])},m.trust=function(a){return a=new String(a),a.$trusted=!0,a};var z,A={view:function(){}},B={},C=0,D=0,E=0;m.module=function(a,b){m.startComputation(),z=a,A=b,B=new b.controller,m.endComputation()},m.redraw=function(){m.render(z,A.view(B)),D=C};var F=0,G=null;m.startComputation=function(){F++},m.endComputation=function(){F=Math.max(F-1,0),0==F&&(g(),G&&(G(),G=null))},m.withAttr=function(a,b){return function(c){b(a in c.currentTarget?c.currentTarget[a]:c.currentTarget.getAttribute(a))}};var H={pathname:"",hash:"#",search:"?"},I=function(){},J={};m.route=function(){if(3==arguments.length){var b=arguments[0],c=arguments[1],d=arguments[2];I=function(a){var e=a.slice(H[m.route.mode].length);h(b,d,e)||m.route(c,!0)};var e="hash"==m.route.mode?"onhashchange":"onpopstate";a[e]=function(){I(a.location[m.route.mode])},G=j,a[e]()}else if(arguments[0].addEventListener){var f=arguments[0],g=arguments[1];g||(f.removeEventListener("click",i),f.addEventListener("click",i))}else if("string"==typeof arguments[0]){var k=arguments[0],l=arguments[1]===!0;a.history.pushState?(G=function(){a.history[l?"replaceState":"pushState"](null,a.document.title,H[m.route.mode]+k),j()},I(H[m.route.mode]+k)):a.location[m.route.mode]=k}},m.route.param=function(a){return J[a]},m.route.mode="search",m.prop=function(a){return function(){return arguments.length&&(a=arguments[0]),a}},m.deferred=function(){var a=[],b=[],c={resolve:function(b){for(var c=0;c-1?new f.constructor(f):f,g.nodes=[n]}else if(g.valueOf()!==f.valueOf()){if(f.$trusted){var q=g.nodes[0],j=[q];if(q){for(;q=q.nextSibling;)j.push(q);d(j);var p=e.lastChild;e.insertAdjacentHTML("beforeend",f),n=p?p.nextSibling:e.firstChild}else e.innerHTML=f}else n=g.nodes[0],e.appendChild(n),n.nodeValue=f;g=new f.constructor(f),g.nodes=[n]}else g.nodes.intact=!0}return g}}function c(b,c,d){for(var e in c){var g=c[e],h=d[e];if(!(e in d)||h!==g||b===a.document.activeElement){if("config"===e)continue;if("function"==typeof g&&0==e.indexOf("on"))String(g)!==String(h)&&(b[e]=f(g,b));else if("style"===e)for(var i in g)(void 0===h||h[i]!==g[i])&&(b.style[i]=g[i]);else e in b?b[e]=g:b.setAttribute(e,g);d[e]=g}}return d}function d(a){for(var b=0;b16)m.redraw();else{var b=a.cancelAnimationFrame||a.clearTimeout,c=a.requestAnimationFrame||a.setTimeout;b(E),E=c(m.redraw,0)}}function h(a,b,c){J={};for(var d in b){if(d==c)return!void m.module(a,b[d]);var e=new RegExp("^"+d.replace(/:[^\/]+/g,"([^\\/]+)")+"$");if(e.test(c))return!void c.replace(e,function(){for(var c=d.match(/:[^\/]+/g),e=[].slice.call(arguments,1,-2),f=0;f0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+n(b):a.data=c(b)),a}function p(a,b){var c=a.match(/:\w+/g);if(c&&b)for(var d=0;d0&&(f.attrs[d]=h.join(" "))}f=e(f),f.attrs=e(f.attrs),f.children=b?a[2]:a[1];for(var j in c)f.attrs[j]=j==d?(f.attrs[j]||"")+" "+c[j]:c[j];return f};var v,w={insertAdjacentHTML:function(b,c){a.document.write(c),a.document.close()},appendChild:function(b){void 0===v&&(v=a.document.createElement("html")),"HTML"==b.nodeName?v=b:v.appendChild(b),a.document.documentElement!==v&&a.document.replaceChild(v,a.document.documentElement)}},x=[],y={};m.render=function(c,d){var e=x.indexOf(c),f=0>e?x.push(c)-1:e,g=c==a.document||c==a.document.documentElement?w:c;y[f]=b(g,d,y[f])},m.trust=function(a){return a=new String(a),a.$trusted=!0,a};var z,A={view:function(){}},B={},C=0,D=0,E=0;m.module=function(a,b){m.startComputation(),z=a,A=b,B=new b.controller,m.endComputation()},m.redraw=function(){m.render(z,A.view(B)),D=C};var F=0,G=null;m.startComputation=function(){F++},m.endComputation=function(){F=Math.max(F-1,0),0==F&&(g(),G&&(G(),G=null))},m.withAttr=function(a,b){return function(c){b(a in c.currentTarget?c.currentTarget[a]:c.currentTarget.getAttribute(a))}};var H={pathname:"",hash:"#",search:"?"},I=function(){},J={};m.route=function(){if(3==arguments.length){var b=arguments[0],c=arguments[1],d=arguments[2];I=function(a){var e=a.slice(H[m.route.mode].length);h(b,d,e)||m.route(c,!0)};var e="hash"==m.route.mode?"onhashchange":"onpopstate";a[e]=function(){I(a.location[m.route.mode])},G=j,a[e]()}else if(arguments[0].addEventListener){var f=arguments[0],g=arguments[1];g||(f.removeEventListener("click",i),f.addEventListener("click",i))}else if("string"==typeof arguments[0]){var k=arguments[0],l=arguments[1]===!0;a.history.pushState?(G=function(){a.history[l?"replaceState":"pushState"](null,a.document.title,H[m.route.mode]+k),j()},I(H[m.route.mode]+k)):a.location[m.route.mode]=k}},m.route.param=function(a){return J[a]},m.route.mode="search",m.prop=function(a){return function(){return arguments.length&&(a=arguments[0]),a}},m.deferred=function(){var a=[],b=[],c={resolve:function(b){for(var c=0;c-kK?IY)p49_ zCw|4Toj4R(JlX{nNa!q)cq~{@sS*&01)GW;s@Rk*5{SZvM+FF}D;9kJe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(t zg1>&uu~H%+D@jRV-E`bs{V~14?5!*ney_(pmNy)Zr)!1?GJy!p9krr{i%}ju9ds~2 ztFOZ%fndwGABT0DLTnF;O(HL)5^_a)+o?5<7a*zj7KK0B;BjiLMU(3)ByY zdwt#XFW1a~i_^rlGM9H0Q5b%&V%i203a6{m%-1S~k2etv-)!dCOqlfa zHDG&~XmGw96NX=R5DctBJBAx}$(VBN(tS#lJbh##9zyDgHmAw)5Y{yr!d*q(Hn0B2 z3OF1AJDNjvf)d&Rb=zuj_^7>LY7Fx>(cqBBdf-g|DY_TdUk@&wjZlU-hc=VXj_Kb7 lv6r9vf1>_xFn96kf4H4EahCt@c>Hlwr|yJaxE#>){{d1X#@GM= diff --git a/mithril.js b/mithril.js index f666364e..596c6049 100644 --- a/mithril.js +++ b/mithril.js @@ -73,7 +73,7 @@ new function(window) { setAttributes(node, data.attrs, cached.attrs) cached.children = build(node, data.children, cached.children) cached.nodes.intact = true - parent.appendChild(node) + if (node.parentNode !== parent) parent.appendChild(node) } if (type.call(data.attrs["config"]) == "[object Function]") data.attrs["config"](node, !isNew) } @@ -120,13 +120,20 @@ new function(window) { function setAttributes(node, dataAttrs, cachedAttrs) { for (var attrName in dataAttrs) { var dataAttr = dataAttrs[attrName] - if (!(attrName in cachedAttrs) || (cachedAttrs[attrName] !== dataAttr) || node === window.document.activeElement) { - cachedAttrs[attrName] = dataAttr - if (attrName == "config") continue - if (attrName.indexOf("on") == 0 && typeof dataAttr == "function") dataAttr = autoredraw(dataAttr, node) - if (attrName == "style") for (var rule in dataAttr) node.style[rule] = dataAttr[rule] + var cachedAttr = cachedAttrs[attrName] + if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr) || node === window.document.activeElement) { + if (attrName === "config") continue + else if (typeof dataAttr == "function" && attrName.indexOf("on") == 0) { + if (String(dataAttr) !== String(cachedAttr)) node[attrName] = autoredraw(dataAttr, node) + } + else if (attrName === "style") { + for (var rule in dataAttr) { + if (cachedAttr === undefined || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] + } + } else if (attrName in node) node[attrName] = dataAttr else node.setAttribute(attrName, dataAttr) + cachedAttrs[attrName] = dataAttr } } return cachedAttrs @@ -141,9 +148,9 @@ new function(window) { return result } function autoredraw(callback, object) { - return function() { + return function(e) { m.startComputation() - var output = callback.apply(object || window, arguments) + var output = callback.call(object, e) m.endComputation() return output }