From fc3d6112c4f45c5056f68a5c8becde4c9c99d9c7 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Thu, 11 Aug 2016 00:29:56 -0400 Subject: [PATCH] build --- mithril.js | 13 +++++-------- mithril.min.js | 44 ++++++++++++++++++++++---------------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/mithril.js b/mithril.js index f8a3e3d5..3b6523a0 100644 --- a/mithril.js +++ b/mithril.js @@ -2,11 +2,11 @@ new function() { var guid = 0, noop = function() {}, HALT = {} function createStream() { function stream() { - if (arguments.length > 0) updateStream(stream, arguments[0], undefined) + if (arguments.length > 0 && arguments[0] !== HALT) updateStream(stream, arguments[0], undefined) return stream._state.value } initStream(stream, arguments) - if (arguments.length > 0) updateStream(stream, arguments[0], undefined) + if (arguments.length > 0 && arguments[0] !== HALT) updateStream(stream, arguments[0], undefined) return stream } function initStream(stream, args) { @@ -19,7 +19,7 @@ function initStream(stream, args) { error: {get: function() { if (!stream._state.errorStream) { var errorStream = function() { - if (arguments.length > 0) updateStream(stream, undefined, arguments[0]) + if (arguments.length > 0 && arguments[0] !== HALT) updateStream(stream, undefined, arguments[0]) return stream._state.error } initStream(errorStream, []) @@ -381,7 +381,7 @@ var renderService = function($window) { if (o === v) oldEnd--, start++ else if (o != null && v != null && o.key === v.key) { updateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), recycling, ns) - insertNode(parent, toFragment(o), getNextSibling(old, oldStart, nextSibling)) + if (start < end) insertNode(parent, toFragment(o), getNextSibling(old, oldStart, nextSibling)) oldEnd--, start++ } else break @@ -748,10 +748,7 @@ var renderService = function($window) { var active = $doc.activeElement // First time rendering into a node clears it out - if (dom.vnodes == null) { - dom.vnodes = [] - dom.textContent = ""; - } + if (dom.vnodes == null) dom.textContent = "" if (!(vnodes instanceof Array)) vnodes = [vnodes] updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), hooks, null, undefined) dom.vnodes = vnodes diff --git a/mithril.min.js b/mithril.min.js index 683fc863..03d17a89 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,40 +1,40 @@ -new function(){function y(){function a(){0=r&&B>=A;){var t=c[r],w=f[A];if(t===w)r++,A++;else if(null!=t&&null!=w&&t.key===w.key)r++,A++,q(a,t,w,e,m(c,r,h),z,k),z&&t.tag===w.tag&&g(a,l(t),h);else if(t=c[v],t===w)v--,A++;else if(null!= -t&&null!=w&&t.key===w.key)q(a,t,w,e,m(c,v+1,h),z,k),g(a,l(t),m(c,r,h)),v--,A++;else break}for(;v>=r&&B>=A;){t=c[v];w=f[B];if(t===w)v--;else if(null!=t&&null!=w&&t.key===w.key)q(a,t,w,e,m(c,v+1,h),z,k),z&&t.tag===w.tag&&g(a,l(t),h),null!=t.dom&&(h=t.dom),v--;else{if(!u){u=c;var t=v,n={},x;for(x=0;x=r&&B>=A;){t=c[v];w=f[B];if(t===w)v--;else if(null!=t&&null!=w&&t.key===w.key)q(a,t,w,e,m(c,v+1,h),z,k),z&&t.tag===w.tag&&g(a,l(t),h),null!=t.dom&&(h=t.dom),v--;else{if(!u){u=c;var t=v,n={},x;for(x=0;xa.indexOf("?")?"?":"&";a+=h+d}return a}function e(a){try{return""!==a?JSON.parse(a):null}catch(b){throw Error(a);}}function k(a){return a.responseText}function q(a,b){if("function"===typeof a)if(b instanceof Array)for(var d= 0;dh.status)p(q(g.type,a));else{var b=Error(h.responseText),d;for(d in a)b[d]=a[d];p.error(b)}}catch(e){p.error(e)}"function"===typeof m&&m()}};l?h.send(g.data):h.send();return p},jsonp:function(g){var e=C.stream();void 0!==g.initialValue&&e(g.initialValue);var k=g.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,h=a.document.createElement("script");a[k]=function(b){h.parentNode.removeChild(h);e(q(g.type, -b));"function"===typeof m&&m();delete a[k]};h.onerror=function(){h.parentNode.removeChild(h);e.error(Error("JSONP request failed"));"function"===typeof m&&m();delete a[k]};null==g.data&&(g.data={});g.url=b(g.url,g.data);g.data[g.callbackKey||"callback"]=k;h.src=d(g.url,g.data);a.document.documentElement.appendChild(h);return e},setCompletionCallback:function(a){m=a}}}(window),G=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1