diff --git a/mithril.js b/mithril.js index 19a6bafe..51a68fbb 100644 --- a/mithril.js +++ b/mithril.js @@ -1103,12 +1103,21 @@ m.route = function($window, renderer, pubsub) { return route }(window, renderService, redrawService) +var dummy = {view: function() {}} m.mount = function(renderer, pubsub) { return function(root, component) { + pubsub.unsubscribe(root.redraw) var run = autoredraw(root, renderer, pubsub, function() { - renderer.render(root, {tag: component}) + renderer.render( + root, + Vnode(component === null ? dummy : component, undefined, undefined, undefined, undefined, undefined) + ) }) run() + if (component === null) { + pubsub.unsubscribe(root.redraw) + delete root.redraw + } } }(renderService, redrawService) m.trust = function(html) { diff --git a/mithril.min.js b/mithril.min.js index 2318a012..2debfa92 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -4,37 +4,37 @@ h&&"function"===typeof a._state.recover)try{var d=a._state.recover();if(d===F)re void 0,p),T(a,p)}}function S(a,b){null!=a&&a.constructor===y&&(b=void 0!==a._state.error?a._state.error:S(a._state.value,a._state.error));return b}function T(a,b){0===Object.keys(a._state.deps).length&&setTimeout(function(){0===Object.keys(a._state.deps).length&&console.error(b)},0)}function ea(a){var b=y(),h=this;return D(b,[h],function(){return W(b,a(h()))},void 0)}function fa(a){var b=y(),h=this;return D(b,[h],function(){return h._state.value},function(){return W(b,a(h._state.error))})}function G(a, b){return D(y(),b,function(){var h=b.filter(V);if(0=r&&B>=A;){var u=c[r],w=f[A];if(u===w)r++,A++;else if(null!=u&&null!=w&&u.key===w.key)r++,A++,p(a,u,w,d,m(c,r,g),z,k),z&&u.tag===w.tag&&e(a,l(u),g);else if(u=c[v],u===w)v--,A++;else if(null!=u&&null!=w&&u.key===w.key)p(a,u,w,d,m(c,v+1,g),z,k),e(a,l(u),m(c,r,g)),v--,A++;else break}for(;v>=r&&B>=A;){u=c[v];w=f[B]; -if(u===w)v--;else if(null!=u&&null!=w&&u.key===w.key)p(a,u,w,d,m(c,v+1,g),z,k),z&&u.tag===w.tag&&e(a,l(u),g),null!=u.dom&&(g=u.dom),v--;else{if(!n){n=c;var u=v,t={},x;for(x=0;xa.indexOf("?")?"?":"&";a+=g+d}return a}function d(a){try{return""!==a?JSON.parse(a):null}catch(b){throw Error(a);}}function g(a){return a.responseText}function p(a,b){if("function"===typeof a)if(b instanceof Array)for(var d=0;dk.status)q(p(e.type, -a));else{var b=Error(k.responseText),d;for(d in a)b[d]=a[d];q.error(b)}}catch(h){q.error(h)}"function"===typeof m&&m()}};l?k.send(e.data):k.send();return q},jsonp:function(e){var d=C.stream();void 0!==e.initialValue&&d(e.initialValue);var g=e.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,k=a.document.createElement("script");a[g]=function(b){k.parentNode.removeChild(k);d(p(e.type,b));"function"===typeof m&&m();delete a[g]};k.onerror=function(){k.parentNode.removeChild(k);d.error(Error("JSONP request failed")); -"function"===typeof m&&m();delete a[g]};null==e.data&&(e.data={});e.url=b(e.url,e.data);e.data[e.callbackKey||"callback"]=g;k.src=h(e.url,e.data);a.document.documentElement.appendChild(k);return d},setCompletionCallback:function(a){m=a}}}(window),H=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1=r&&B>=A;){var t=c[r],w=e[A];if(t===w)r++,A++;else if(null!=t&&null!=w&&t.key===w.key)r++,A++,p(a,t,w,d,m(c,r,g),z,k),z&&t.tag===w.tag&&f(a,l(t),g);else if(t=c[v],t===w)v--,A++;else if(null!=t&&null!=w&&t.key===w.key)p(a,t,w,d,m(c,v+1,g),z,k),f(a,l(t),m(c,r,g)),v--,A++;else break}for(;v>=r&&B>=A;){t=c[v];w=e[B]; +if(t===w)v--;else if(null!=t&&null!=w&&t.key===w.key)p(a,t,w,d,m(c,v+1,g),z,k),z&&t.tag===w.tag&&f(a,l(t),g),null!=t.dom&&(g=t.dom),v--;else{if(!u){u=c;var t=v,n={},x;for(x=0;xa.indexOf("?")?"?":"&";a+=g+d}return a}function d(a){try{return""!==a?JSON.parse(a):null}catch(b){throw Error(a);}}function g(a){return a.responseText}function p(a,b){if("function"===typeof a)if(b instanceof Array)for(var d=0;dk.status)q(p(f.type, +a));else{var b=Error(k.responseText),d;for(d in a)b[d]=a[d];q.error(b)}}catch(h){q.error(h)}"function"===typeof m&&m()}};l?k.send(f.data):k.send();return q},jsonp:function(f){var d=C.stream();void 0!==f.initialValue&&d(f.initialValue);var g=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,k=a.document.createElement("script");a[g]=function(b){k.parentNode.removeChild(k);d(p(f.type,b));"function"===typeof m&&m();delete a[g]};k.onerror=function(){k.parentNode.removeChild(k);d.error(Error("JSONP request failed")); +"function"===typeof m&&m();delete a[g]};null==f.data&&(f.data={});f.url=b(f.url,f.data);f.data[f.callbackKey||"callback"]=g;k.src=h(f.url,f.data);a.document.documentElement.appendChild(k);return d},setCompletionCallback:function(a){m=a}}}(window),H=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1