From 11940b427b6497d4350ad0781d7b5041edbc86bf Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Fri, 18 May 2018 18:50:40 +0000 Subject: [PATCH] Bundled output for commit 6097cfb2e9146c63a3cad3816cd18511b37e7808 [skip ci] --- README.md | 2 +- mithril.js | 12 +++---- mithril.min.js | 88 +++++++++++++++++++++++++------------------------- 3 files changed, 49 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index 296c4c32..6ddbbb0a 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ mithril.js [![NPM Version](https://img.shields.io/npm/v/mithril.svg)](https://ww ## What is Mithril? -A modern client-side Javascript framework for building Single Page Applications. It's small (8.30 KB gzipped), fast and provides routing and XHR utilities out of the box. +A modern client-side Javascript framework for building Single Page Applications. It's small (8.29 KB gzipped), fast and provides routing and XHR utilities out of the box. Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍. diff --git a/mithril.js b/mithril.js index 11b40899..8b354041 100644 --- a/mithril.js +++ b/mithril.js @@ -78,14 +78,10 @@ function execSelector(state, attrs, children) { return Vnode(state.tag, attrs.key, hasAttrs ? attrs : undefined, childList, text) } function hyperscript(selector) { - // Because sloppy mode sucks - var attrs = arguments[1], start = 2, children if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") { throw Error("The selector must be either a string or a component."); } - if (typeof selector === "string") { - var cached = selectorCache[selector] || compileSelector(selector) - } + var attrs = arguments[1], start = 2, children if (attrs == null) { attrs = {} } else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) { @@ -101,7 +97,7 @@ function hyperscript(selector) { } var normalized = Vnode.normalizeChildren(children) if (typeof selector === "string") { - return execSelector(cached, attrs, normalized) + return execSelector(selectorCache[selector] || compileSelector(selector), attrs, normalized) } else { return Vnode(selector, attrs.key, attrs, normalized) } @@ -635,12 +631,12 @@ var coreRenderer = function($window) { // In the other scenarios (swaps, upwards traversal, map-based diff), // the new vnodes list is traversed upwards. The DOM nodes at the bottom of the list reflect the // bottom part of the new vnodes list, and we can use the `v.dom` value of the previous node - // as the next0 sibling (cached0 in the `nextSibling` variable). + // as the next0 sibling (cached in the `nextSibling` variable). // ## DOM node moves // // In most scenarios `updateNode()` and `createNode()` perform the DOM operations. However, // this is not the case if the node moved (second and fourth part of the diff algo). We move - // the old DOM nodes before updateNode runs0 because it enables us to use the cached0 `nextSibling` + // the old DOM nodes before updateNode runs0 because it enables us to use the cached `nextSibling` // variable rather than fetching it using `getNextSibling()`. // // The fourth part of the diff currently inserts nodes unconditionally, leading to issues diff --git a/mithril.min.js b/mithril.min.js index 67c396ce..3c3b8979 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,45 +1,45 @@ -(function(){function x(a,d,e,f,k,l){return{tag:a,key:d,attrs:e,children:f,text:k,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0,skip:!1}}function M(a){for(var d in a)if(C.call(a,d))return!1;return!0}function w(a){var d=arguments[1],e=2;if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a){var f;if(!(f=N[a])){var k="div";for(var l=[],m={};f=R.exec(a);){var p=f[1], -u=f[2];""===p&&""!==u?k=u:"#"===p?m.id=u:"."===p?l.push(u):"["===f[3][0]&&((p=f[6])&&(p=p.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===f[4]?l.push(p):m[f[4]]=""===p?p:p||!0)}0b.indexOf("?")?"?":"&";b+=e+d}return b}function m(b){try{return""!==b?JSON.parse(b):null}catch(A){throw Error(b);}}function p(b){return b.responseText}function u(b,a){if("function"=== -typeof b)if(Array.isArray(a))for(var d=0;dh.status||304===h.status||U.test(b.url))d(u(b.type,a));else{var f=Error(h.responseText);f.code=h.status;f.response=a;e(f)}}catch(V){e(V)}};f&&null!=b.data?h.send(b.data):h.send()});return!0===b.background?A:h(A)},jsonp:function(b,p){var h=e();b=f(b,p);var m=new d(function(d,e){var f=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+r++,h=a.document.createElement("script");a[f]=function(e){h.parentNode.removeChild(h);d(u(b.type,e));delete a[f]};h.onerror=function(){h.parentNode.removeChild(h); -e(Error("JSONP request failed"));delete a[f]};null==b.data&&(b.data={});b.url=k(b.url,b.data);b.data[b.callbackKey||"callback"]=f;h.src=l(b.url,b.data);a.document.documentElement.appendChild(h)});return!0===b.background?m:h(m)},setCompletionCallback:function(b){z=b}}}(window,n),Q=function(a){function d(b,c){if(b.state!==c)throw Error("`vnode.state` must not be modified");}function e(b){var c=b.state;try{return this.apply(c,arguments)}finally{d(b,c)}}function f(b,c,g,a,d,e,f){for(;g'+c.children+"",q=q.firstChild):q.innerHTML=c.children;c.dom=q.firstChild;c.domSize=q.childNodes.length;for(c=y.createDocumentFragment();a=q.firstChild;)c.appendChild(a);z(b,c,d)}function m(b, -c,a,d,e,l){if(c!==a&&(null!=c||null!=a))if(null==c)f(b,a,0,a.length,d,e,l);else if(null==a)A(c,0,c.length);else{for(var q=0,g=0,t=!0,m=!0;g=g&&B>=q;)if(v=c[g],t=a[q],null==v)g++;else if(null==t)q++;else if(v.key===t.key)g++,q++,v!==t&&p(b,v,t,d,r(c,g,e),l);else if(t=a[B],null==v)g++;else if(null== -t)B--;else if(v.key===t.key)g++,q=g&&B>=q;){v=c[m];t=a[B];if(null==v)m--;else{if(null!=t)if(v.key===t.key)v!==t&&p(b,v,t,d,e,l),null!=t.dom&&(e=t.dom),m--;else{if(null==n){n=c;v=g;for(var y=m,x={};vm&&A(c,q,c.length);a.length>m&&f(b,a,q,a.length,d,e,l)}}}function p(a,c,g,d,f,r){var q=c.tag;if(q===g.tag){g.state=c.state;g.events=c.events;var t;var A;null!=g.attrs&&"function"===typeof g.attrs.onbeforeupdate&&(t=e.call(g.attrs.onbeforeupdate,g,c));"string"!==typeof g.tag&&"function"===typeof g.state.onbeforeupdate&& -(A=e.call(g.state.onbeforeupdate,g,c));void 0===t&&void 0===A||t||A?t=!1:(g.dom=c.dom,g.domSize=c.domSize,g.instance=c.instance,t=!0);if(!t)if("string"===typeof q)switch(null!=g.attrs&&J(g.attrs,g,d),q){case "#":c.children.toString()!==g.children.toString()&&(c.dom.nodeValue=g.children);g.dom=c.dom;break;case "<":c.children!==g.children?(u(c),l(a,g,r,f)):(g.dom=c.dom,g.domSize=c.domSize);break;case "[":m(a,c.children,g.children,d,f,r);c=0;d=g.children;g.dom=null;if(null!=d){for(var n=0;nb.indexOf("?")?"?":"&";b+=f+d}return b}function h(b){try{return""!==b?JSON.parse(b):null}catch(A){throw Error(b);}}function p(b){return b.responseText}function r(b,a){if("function"=== +typeof b)if(Array.isArray(a))for(var d=0;dk.status||304===k.status||U.test(b.url))d(r(b.type,a));else{var e=Error(k.responseText);e.code=k.status;e.response=a;f(e)}}catch(V){f(V)}};e&&null!=b.data?k.send(b.data):k.send()});return!0===b.background?A:k(A)},jsonp:function(b,p){var k=e();b=f(b,p);var h=new d(function(d,f){var e=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+t++,k=a.document.createElement("script");a[e]=function(f){k.parentNode.removeChild(k);d(r(b.type,f));delete a[e]};k.onerror=function(){k.parentNode.removeChild(k); +f(Error("JSONP request failed"));delete a[e]};null==b.data&&(b.data={});b.url=u(b.url,b.data);b.data[b.callbackKey||"callback"]=e;k.src=l(b.url,b.data);a.document.documentElement.appendChild(k)});return!0===b.background?h:k(h)},setCompletionCallback:function(b){y=b}}}(window,m),Q=function(a){function d(b,c){if(b.state!==c)throw Error("`vnode.state` must not be modified");}function e(b){var c=b.state;try{return this.apply(c,arguments)}finally{d(b,c)}}function f(b,c,g,a,d,f,e){for(;g'+c.children+"",n=n.firstChild):n.innerHTML=c.children;c.dom=n.firstChild;c.domSize=n.childNodes.length;for(c=z.createDocumentFragment();a=n.firstChild;)c.appendChild(a);y(b,c,d)}function h(b, +c,a,d,e,h){if(c!==a&&(null!=c||null!=a))if(null==c)f(b,a,0,a.length,d,e,h);else if(null==a)A(c,0,c.length);else{for(var n=0,g=0,q=!0,l=!0;g=g&&B>=n;)if(v=c[g],q=a[n],null==v)g++;else if(null==q)n++;else if(v.key===q.key)g++,n++,v!==q&&p(b,v,q,d,t(c,g,e),h);else if(q=a[B],null==v)g++;else if(null== +q)B--;else if(v.key===q.key)g++,n=g&&B>=n;){v=c[l];q=a[B];if(null==v)l--;else{if(null!=q)if(v.key===q.key)v!==q&&p(b,v,q,d,e,h),null!=q.dom&&(e=q.dom),l--;else{if(null==m){m=c;v=g;for(var z=l,x={};vl&&A(c,n,c.length);a.length>l&&f(b,a,n,a.length,d,e,h)}}}function p(a,c,g,d,f,t){var n=c.tag;if(n===g.tag){g.state=c.state;g.events=c.events;var q;var A;null!=g.attrs&&"function"===typeof g.attrs.onbeforeupdate&&(q=e.call(g.attrs.onbeforeupdate,g,c));"string"!==typeof g.tag&&"function"===typeof g.state.onbeforeupdate&& +(A=e.call(g.state.onbeforeupdate,g,c));void 0===q&&void 0===A||q||A?q=!1:(g.dom=c.dom,g.domSize=c.domSize,g.instance=c.instance,q=!0);if(!q)if("string"===typeof n)switch(null!=g.attrs&&J(g.attrs,g,d),n){case "#":c.children.toString()!==g.children.toString()&&(c.dom.nodeValue=g.children);g.dom=c.dom;break;case "<":c.children!==g.children?(r(c),l(a,g,t,f)):(g.dom=c.dom,g.domSize=c.domSize);break;case "[":h(a,c.children,g.children,d,f,t);c=0;d=g.children;g.dom=null;if(null!=d){for(var m=0;m