Bundled output for commit 6097cfb2e9 [skip ci]
This commit is contained in:
parent
6097cfb2e9
commit
11940b427b
3 changed files with 49 additions and 53 deletions
|
|
@ -18,7 +18,7 @@ mithril.js [](https://ww
|
|||
|
||||
## What is Mithril?
|
||||
|
||||
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.30 KB<!-- /size --> 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 (<!-- size -->8.29 KB<!-- /size --> 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 👍.
|
||||
|
||||
|
|
|
|||
12
mithril.js
12
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
|
||||
|
|
|
|||
88
mithril.min.js
vendored
88
mithril.min.js
vendored
|
|
@ -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)}0<l.length&&(m.className=l.join(" "));f=N[a]={tag:k,attrs:m}}}if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length===e+1)k=arguments[e],Array.isArray(k)||(k=[k]);else for(k=[];e<arguments.length;)k.push(arguments[e++]);e=x.normalizeChildren(k);if("string"===typeof a){k=
|
||||
!1;var r,z;l=d.className||d["class"];if(!M(f.attrs)&&!M(d)){m={};for(var b in d)C.call(d,b)&&(m[b]=d[b]);d=m}for(b in f.attrs)C.call(f.attrs,b)&&(d[b]=f.attrs[b]);void 0!==l&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=l),null!=f.attrs.className&&(d.className=f.attrs.className+" "+l));for(b in d)if(C.call(d,b)&&"key"!==b){k=!0;break}Array.isArray(e)&&1===e.length&&null!=e[0]&&"#"===e[0].tag?z=e[0].children:r=e;return x(f.tag,d.key,k?d:void 0,r,z)}return x(a,d.key,d,e)}function S(a){var d=
|
||||
0,e=null,f="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var k=Date.now()-d;null===e&&(e=f(function(){e=null;a();d=Date.now()},16-k))}}x.normalize=function(a){return Array.isArray(a)?x("[",void 0,void 0,x.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?x("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};x.normalizeChildren=function(a){for(var d=0;d<a.length;d++)a[d]=x.normalize(a[d]);return a};var R=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,
|
||||
N={},C={}.hasOwnProperty;w.trust=function(a){null==a&&(a="");return x("<",void 0,void 0,a,void 0,void 0)};w.fragment=function(a,d){return x("[",a.key,a,x.normalizeChildren(d),void 0,void 0)};var n=function(a){function d(a,b){return function G(d){var h;try{if(!b||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(h=d.then))r(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",d);for(var e=0;e<a.length;e++)a[e](d);k.length=0;l.length=0;u.state=b;u.retry=
|
||||
function(){G(d)}});else{if(d===f)throw new TypeError("Promise can't be resolved w/ itself");e(h.bind(d))}}catch(T){p(T)}}}function e(a){function b(b){return function(a){0<d++||b(a)}}var d=0,e=b(p);try{a(b(m),e)}catch(G){e(G)}}if(!(this instanceof n))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var f=this,k=[],l=[],m=d(k,!0),p=d(l,!1),u=f._instance={resolvers:k,rejectors:l},r="function"===typeof setImmediate?setImmediate:
|
||||
setTimeout;e(a)};n.prototype.then=function(a,d){function e(a,d,e,m){d.push(function(b){if("function"!==typeof a)e(b);else try{k(a(b))}catch(A){l&&l(A)}});"function"===typeof f.retry&&m===f.state&&f.retry()}var f=this._instance,k,l,m=new n(function(a,d){k=a;l=d});e(a,f.resolvers,k,!0);e(d,f.rejectors,l,!1);return m};n.prototype["catch"]=function(a){return this.then(null,a)};n.prototype["finally"]=function(a){return this.then(function(d){return n.resolve(a()).then(function(){return d})},function(d){return n.resolve(a()).then(function(){return n.reject(d)})})};
|
||||
n.resolve=function(a){return a instanceof n?a:new n(function(d){d(a)})};n.reject=function(a){return new n(function(d,e){e(a)})};n.all=function(a){return new n(function(d,e){var f=a.length,k=0,l=[];if(0===a.length)d([]);else for(var m=0;m<a.length;m++)(function(p){function u(a){k++;l[p]=a;k===f&&d(l)}null==a[p]||"object"!==typeof a[p]&&"function"!==typeof a[p]||"function"!==typeof a[p].then?u(a[p]):a[p].then(u,e)})(m)})};n.race=function(a){return new n(function(d,e){for(var f=0;f<a.length;f++)a[f].then(d,
|
||||
e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=n:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=n.prototype["finally"]),n=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=n:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=n.prototype["finally"]),n=global.Promise);var E=function(a){function d(a,f){if(Array.isArray(f))for(var k=0;k<f.length;k++)d(a+"["+k+"]",f[k]);
|
||||
else if("[object Object]"===Object.prototype.toString.call(f))for(k in f)d(a+"["+k+"]",f[k]);else e.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var e=[],f;for(f in a)d(f,a[f]);return e.join("&")},U=/^file:\/\//i,K=function(a,d){function e(){function b(){0===--a&&"function"===typeof z&&z()}var a=0;return function D(d){var e=d.then;d.then=function(){a++;var f=e.apply(d,arguments);f.then(b,function(d){b();
|
||||
if(0===a)throw d;});return D(f)};return d}}function f(b,a){if("string"===typeof b){var d=b;b=a||{};null==b.url&&(b.url=d)}return b}function k(b,a){if(null==a)return b;for(var d=b.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var f=d[e].slice(1);null!=a[f]&&(b=b.replace(d[e],a[f]))}return b}function l(b,a){var d=E(a);if(""!==d){var e=0>b.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;d<a.length;d++)a[d]=new b(a[d]);else return new b(a);return a}var r=0,z;return{request:function(b,r){var h=e();b=f(b,r);var A=new d(function(d,e){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var f="GET"===b.method||"TRACE"===b.method?!1:"boolean"===typeof b.useBody?b.useBody:!0;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof b.deserialize&&
|
||||
(b.deserialize=m);"function"!==typeof b.extract&&(b.extract=p);b.url=k(b.url,b.data);f?b.data=b.serialize(b.data):b.url=l(b.url,b.data);var h=new a.XMLHttpRequest,r=!1,A=h.abort;h.abort=function(){r=!0;A.call(h)};h.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize!==JSON.stringify||!f||b.headers&&b.headers.hasOwnProperty("Content-Type")||h.setRequestHeader("Content-Type","application/json; charset=utf-8");
|
||||
b.deserialize!==m||b.headers&&b.headers.hasOwnProperty("Accept")||h.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(h.withCredentials=b.withCredentials);b.timeout&&(h.timeout=b.timeout);for(var z in b.headers)({}).hasOwnProperty.call(b.headers,z)&&h.setRequestHeader(z,b.headers[z]);"function"===typeof b.config&&(h=b.config(h,b)||h);h.onreadystatechange=function(){if(!r&&4===h.readyState)try{var a=b.extract!==p?b.extract(h,b):b.deserialize(b.extract(h,b));if(b.extract!==p||
|
||||
200<=h.status&&300>h.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<a;g++){var q=c[g];
|
||||
null!=q&&k(b,q,d,f,e)}}function k(q,c,g,a,d){var h=c.tag;if("string"===typeof h)switch(c.state={},null!=c.attrs&&I(c.attrs,c,g),h){case "#":c.dom=y.createTextNode(c.children);z(q,c.dom,d);break;case "<":l(q,c,a,d);break;case "[":var u=y.createDocumentFragment();null!=c.children&&(h=c.children,f(u,h,0,h.length,g,null,a));c.dom=u.firstChild;c.domSize=u.childNodes.length;z(q,u,d);break;default:var t=c.tag,p=(h=c.attrs)&&h.is;t=(a=c.attrs&&c.attrs.xmlns||P[c.tag]||a)?p?y.createElementNS(a,t,{is:p}):y.createElementNS(a,
|
||||
t):p?y.createElement(t,{is:p}):y.createElement(t);c.dom=t;if(null!=h)for(u in p=a,h)D(c,u,null,h[u],p);z(q,t,d);null!=c.attrs&&null!=c.attrs.contenteditable?b(c):(null!=c.text&&(""!==c.text?t.textContent=c.text:c.children=[x("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(q=c.children,f(t,q,0,q.length,g,null,a),g=c.attrs,"select"===c.tag&&null!=g&&("value"in g&&D(c,"value",null,g.value,void 0),"selectedIndex"in g&&D(c,"selectedIndex",null,g.selectedIndex,void 0))))}else{a:{if("function"===
|
||||
typeof c.tag.view){c.state=Object.create(c.tag);u=c.state.view;if(null!=u.$$reentrantLock$$)break a;u.$$reentrantLock$$=!0}else{c.state=void 0;u=c.tag;if(null!=u.$$reentrantLock$$)break a;u.$$reentrantLock$$=!0;c.state=null!=c.tag.prototype&&"function"===typeof c.tag.prototype.view?new c.tag(c):c.tag(c)}null!=c.attrs&&I(c.attrs,c,g);I(c.state,c,g);c.instance=x.normalize(e.call(c.state.view,c));if(c.instance===c)throw Error("A view cannot return the vnode it received as argument");u.$$reentrantLock$$=
|
||||
null}null!=c.instance?(k(q,c.instance,g,a,d),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0):c.domSize=0}}function l(b,c,a,d){var q=c.children.match(/^\s*?<(\w+)/im)||[];q=y.createElement(E[q[1]]||"div");"http://www.w3.org/2000/svg"===a?(q.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+c.children+"</svg>",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<c.length;g++)if(null!=c[g]){t=null!=c[g].key;break}for(;q<a.length;q++)if(null!=a[q]){m=null!=a[q].key;break}if(t!==m)A(c,g,c.length),f(b,a,q,a.length,d,e,l);else if(m){m=c.length-1;for(var B=a.length-1,n,v;m>=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<B--&&z(b,u(v),e),v!==t&&p(b,v,t,d,e,l),null!=t.dom&&(e=t.dom);else break;for(;m>=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={};v<y;v++){var w=n[v];null!=w&&(w=w.key,null!=w&&(x[w]=v))}n=x}null!=t&&(v=n[t.key],null==v?k(b,t,d,l,e):(v=c[v],z(b,u(v),e),v!==t&&p(b,v,t,d,e,l),v.skip=!0),null!=t.dom&&(e=t.dom))}B--}if(B<q)break}f(b,a,q,B+1,d,e,l);A(c,g,m+
|
||||
1)}else{m=c.length<a.length?c.length:a.length;for(q=q<g?q:g;q<m;q++)v=c[q],t=a[q],v===t||null==v&&null==t||(null==v?k(b,t,d,l,r(c,q+1,e)):null==t?h(v):p(b,v,t,d,r(c,q+1,e),l));c.length>m&&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;n<d.length;n++)r=
|
||||
d[n],null!=r&&null!=r.dom&&(null==g.dom&&(g.dom=r.dom),c+=r.domSize||1);1!==c&&(g.domSize=c)}break;default:a=g.dom=c.dom;r=g.attrs&&g.attrs.xmlns||P[g.tag]||r;"textarea"===g.tag&&(null==g.attrs&&(g.attrs={}),null!=g.text&&(g.attrs.value=g.text,g.text=void 0));f=c.attrs;q=g.attrs;t=r;if(null!=q)for(n in q)D(g,n,f&&f[n],q[n],t);if(null!=f)for(n in f)null!=q&&n in q||("className"===n&&(n="class"),"o"!==n[0]||"n"!==n[1]||w(n)?"key"!==n&&g.dom.removeAttribute(n):O(g,n,void 0));null!=g.attrs&&null!=g.attrs.contenteditable?
|
||||
b(g):null!=c.text&&null!=g.text&&""!==g.text?c.text.toString()!==g.text.toString()&&(c.dom.firstChild.nodeValue=g.text):(null!=c.text&&(c.children=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=g.text&&(g.children=[x("#",void 0,void 0,g.text,void 0,void 0)]),m(a,c.children,g.children,d,null,r))}else{g.instance=x.normalize(e.call(g.state.view,g));if(g.instance===g)throw Error("A view cannot return the vnode it received as argument");null!=g.attrs&&J(g.attrs,g,d);J(g.state,g,d);null!=
|
||||
g.instance?(null==c.instance?k(a,g.instance,d,r,f):p(a,c.instance,g.instance,d,f,r),g.dom=g.instance.dom,g.domSize=g.instance.domSize):null!=c.instance?(h(c.instance),g.dom=void 0,g.domSize=0):(g.dom=c.dom,g.domSize=c.domSize)}}else h(c),k(a,g,d,r,f)}function u(a){var c=a.domSize;if(null!=c||null==a.dom){var b=y.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function r(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=
|
||||
a[c].dom)return a[c].dom;return b}function z(a,c,b){null!=b?a.insertBefore(c,b):a.appendChild(c)}function b(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function A(a,c,b){for(;c<b;c++){var q=a[c];null!=q&&(q.skip?q.skip=!1:h(q))}}function h(a){function c(){if(++q===b&&(d(a,f),n(a),a.dom)){var c=a.domSize||1;if(1<c)for(var g=
|
||||
a.dom;--c;){var e=g.nextSibling,h=e.parentNode;null!=h&&h.removeChild(e)}c=a.dom;g=c.parentNode;null!=g&&g.removeChild(c)}}var b=1,q=0,f=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var h=e.call(a.attrs.onbeforeremove,a);null!=h&&"function"===typeof h.then&&(b++,h.then(c,c))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(h=e.call(a.state.onbeforeremove,a),null!=h&&"function"===typeof h.then&&(b++,h.then(c,c)));c()}function n(a){a.attrs&&"function"===typeof a.attrs.onremove&&
|
||||
e.call(a.attrs.onremove,a);if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&n(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&n(b)}}function D(a,c,b,d,e){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return O(a,c,d);if("undefined"===typeof d&&"value"===c&&b!==d)a.dom.value="";else if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===y.activeElement||
|
||||
"option"===a.tag&&a.dom.parentNode===y.activeElement||"object"===typeof d)&&void 0!==d){var g=a.dom;if("xlink:"===c.slice(0,6))g.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&"object"===typeof d&&d!==a){for(var f in d)d[f]!==a[f]&&(g.style[f]=d[f]);for(f in a)f in d||(g.style[f]="")}else if(a===d&&(g.style.cssText="",a=null),null==d)g.style.cssText="";else if("string"===typeof d)g.style.cssText=d;else for(f in"string"===typeof a&&
|
||||
(g.style.cssText=""),d)g.style[f]=d[f];else if(c in g&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===e&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){f=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===f&&a.dom===y.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===y.activeElement)return}else if(null!==b&&a.dom.value===f&&a.dom===y.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===f)return}"input"===
|
||||
(function(){function x(a,d,e,f,u,l){return{tag:a,key:d,attrs:e,children:f,text:u,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){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.");var d=arguments[1],e=2;if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},e=1;if(arguments.length===
|
||||
e+1){var f=arguments[e];Array.isArray(f)||(f=[f])}else for(f=[];e<arguments.length;)f.push(arguments[e++]);e=x.normalizeChildren(f);if("string"===typeof a){if(!(f=N[a])){for(var u="div",l=[],h={};f=R.exec(a);){var p=f[1],r=f[2];""===p&&""!==r?u=r:"#"===p?h.id=r:"."===p?l.push(r):"["===f[3][0]&&((p=f[6])&&(p=p.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===f[4]?l.push(p):h[f[4]]=""===p?p:p||!0)}0<l.length&&(h.className=l.join(" "));f=N[a]={tag:u,attrs:h}}u=!1;var t,y;l=d.className||d["class"];
|
||||
if(!M(f.attrs)&&!M(d)){h={};for(var b in d)C.call(d,b)&&(h[b]=d[b]);d=h}for(b in f.attrs)C.call(f.attrs,b)&&(d[b]=f.attrs[b]);void 0!==l&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=l),null!=f.attrs.className&&(d.className=f.attrs.className+" "+l));for(b in d)if(C.call(d,b)&&"key"!==b){u=!0;break}Array.isArray(e)&&1===e.length&&null!=e[0]&&"#"===e[0].tag?y=e[0].children:t=e;return x(f.tag,d.key,u?d:void 0,t,y)}return x(a,d.key,d,e)}function S(a){var d=0,e=null,f="function"===typeof requestAnimationFrame?
|
||||
requestAnimationFrame:setTimeout;return function(){var u=Date.now()-d;null===e&&(e=f(function(){e=null;a();d=Date.now()},16-u))}}x.normalize=function(a){return Array.isArray(a)?x("[",void 0,void 0,x.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?x("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};x.normalizeChildren=function(a){for(var d=0;d<a.length;d++)a[d]=x.normalize(a[d]);return a};var R=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,N={},C={}.hasOwnProperty;
|
||||
w.trust=function(a){null==a&&(a="");return x("<",void 0,void 0,a,void 0,void 0)};w.fragment=function(a,d){return x("[",a.key,a,x.normalizeChildren(d),void 0,void 0)};var m=function(a){function d(a,b){return function G(d){var k;try{if(!b||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(k=d.then))t(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",d);for(var f=0;f<a.length;f++)a[f](d);u.length=0;l.length=0;r.state=b;r.retry=function(){G(d)}});
|
||||
else{if(d===f)throw new TypeError("Promise can't be resolved w/ itself");e(k.bind(d))}}catch(T){p(T)}}}function e(a){function b(b){return function(a){0<d++||b(a)}}var d=0,f=b(p);try{a(b(h),f)}catch(G){f(G)}}if(!(this instanceof m))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var f=this,u=[],l=[],h=d(u,!0),p=d(l,!1),r=f._instance={resolvers:u,rejectors:l},t="function"===typeof setImmediate?setImmediate:setTimeout;e(a)};
|
||||
m.prototype.then=function(a,d){function e(a,d,e,h){d.push(function(b){if("function"!==typeof a)e(b);else try{u(a(b))}catch(A){l&&l(A)}});"function"===typeof f.retry&&h===f.state&&f.retry()}var f=this._instance,u,l,h=new m(function(a,d){u=a;l=d});e(a,f.resolvers,u,!0);e(d,f.rejectors,l,!1);return h};m.prototype["catch"]=function(a){return this.then(null,a)};m.prototype["finally"]=function(a){return this.then(function(d){return m.resolve(a()).then(function(){return d})},function(d){return m.resolve(a()).then(function(){return m.reject(d)})})};
|
||||
m.resolve=function(a){return a instanceof m?a:new m(function(d){d(a)})};m.reject=function(a){return new m(function(d,e){e(a)})};m.all=function(a){return new m(function(d,e){var f=a.length,u=0,l=[];if(0===a.length)d([]);else for(var h=0;h<a.length;h++)(function(p){function r(a){u++;l[p]=a;u===f&&d(l)}null==a[p]||"object"!==typeof a[p]&&"function"!==typeof a[p]||"function"!==typeof a[p].then?r(a[p]):a[p].then(r,e)})(h)})};m.race=function(a){return new m(function(d,e){for(var f=0;f<a.length;f++)a[f].then(d,
|
||||
e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=m:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=m.prototype["finally"]),m=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=m:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=m.prototype["finally"]),m=global.Promise);var E=function(a){function d(a,f){if(Array.isArray(f))for(var h=0;h<f.length;h++)d(a+"["+h+"]",f[h]);
|
||||
else if("[object Object]"===Object.prototype.toString.call(f))for(h in f)d(a+"["+h+"]",f[h]);else e.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var e=[],f;for(f in a)d(f,a[f]);return e.join("&")},U=/^file:\/\//i,K=function(a,d){function e(){function b(){0===--a&&"function"===typeof y&&y()}var a=0;return function D(d){var f=d.then;d.then=function(){a++;var e=f.apply(d,arguments);e.then(b,function(d){b();
|
||||
if(0===a)throw d;});return D(e)};return d}}function f(b,a){if("string"===typeof b){var d=b;b=a||{};null==b.url&&(b.url=d)}return b}function u(b,a){if(null==a)return b;for(var d=b.match(/:[^\/]+/gi)||[],f=0;f<d.length;f++){var e=d[f].slice(1);null!=a[e]&&(b=b.replace(d[f],a[e]))}return b}function l(b,a){var d=E(a);if(""!==d){var f=0>b.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;d<a.length;d++)a[d]=new b(a[d]);else return new b(a);return a}var t=0,y;return{request:function(b,t){var k=e();b=f(b,t);var A=new d(function(d,f){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var e="GET"===b.method||"TRACE"===b.method?!1:"boolean"===typeof b.useBody?b.useBody:!0;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof b.deserialize&&
|
||||
(b.deserialize=h);"function"!==typeof b.extract&&(b.extract=p);b.url=u(b.url,b.data);e?b.data=b.serialize(b.data):b.url=l(b.url,b.data);var k=new a.XMLHttpRequest,t=!1,A=k.abort;k.abort=function(){t=!0;A.call(k)};k.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize!==JSON.stringify||!e||b.headers&&b.headers.hasOwnProperty("Content-Type")||k.setRequestHeader("Content-Type","application/json; charset=utf-8");
|
||||
b.deserialize!==h||b.headers&&b.headers.hasOwnProperty("Accept")||k.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(k.withCredentials=b.withCredentials);b.timeout&&(k.timeout=b.timeout);for(var y in b.headers)({}).hasOwnProperty.call(b.headers,y)&&k.setRequestHeader(y,b.headers[y]);"function"===typeof b.config&&(k=b.config(k,b)||k);k.onreadystatechange=function(){if(!t&&4===k.readyState)try{var a=b.extract!==p?b.extract(k,b):b.deserialize(b.extract(k,b));if(b.extract!==p||
|
||||
200<=k.status&&300>k.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<a;g++){var n=c[g];
|
||||
null!=n&&u(b,n,d,e,f)}}function u(n,c,g,a,d){var k=c.tag;if("string"===typeof k)switch(c.state={},null!=c.attrs&&I(c.attrs,c,g),k){case "#":c.dom=z.createTextNode(c.children);y(n,c.dom,d);break;case "<":l(n,c,a,d);break;case "[":var r=z.createDocumentFragment();null!=c.children&&(k=c.children,f(r,k,0,k.length,g,null,a));c.dom=r.firstChild;c.domSize=r.childNodes.length;y(n,r,d);break;default:var q=c.tag,h=(k=c.attrs)&&k.is;q=(a=c.attrs&&c.attrs.xmlns||P[c.tag]||a)?h?z.createElementNS(a,q,{is:h}):z.createElementNS(a,
|
||||
q):h?z.createElement(q,{is:h}):z.createElement(q);c.dom=q;if(null!=k)for(r in h=a,k)D(c,r,null,k[r],h);y(n,q,d);null!=c.attrs&&null!=c.attrs.contenteditable?b(c):(null!=c.text&&(""!==c.text?q.textContent=c.text:c.children=[x("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(n=c.children,f(q,n,0,n.length,g,null,a),g=c.attrs,"select"===c.tag&&null!=g&&("value"in g&&D(c,"value",null,g.value,void 0),"selectedIndex"in g&&D(c,"selectedIndex",null,g.selectedIndex,void 0))))}else{a:{if("function"===
|
||||
typeof c.tag.view){c.state=Object.create(c.tag);r=c.state.view;if(null!=r.$$reentrantLock$$)break a;r.$$reentrantLock$$=!0}else{c.state=void 0;r=c.tag;if(null!=r.$$reentrantLock$$)break a;r.$$reentrantLock$$=!0;c.state=null!=c.tag.prototype&&"function"===typeof c.tag.prototype.view?new c.tag(c):c.tag(c)}null!=c.attrs&&I(c.attrs,c,g);I(c.state,c,g);c.instance=x.normalize(e.call(c.state.view,c));if(c.instance===c)throw Error("A view cannot return the vnode it received as argument");r.$$reentrantLock$$=
|
||||
null}null!=c.instance?(u(n,c.instance,g,a,d),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0):c.domSize=0}}function l(b,c,a,d){var n=c.children.match(/^\s*?<(\w+)/im)||[];n=z.createElement(E[n[1]]||"div");"http://www.w3.org/2000/svg"===a?(n.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+c.children+"</svg>",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<c.length;g++)if(null!=c[g]){q=null!=c[g].key;break}for(;n<a.length;n++)if(null!=a[n]){l=null!=a[n].key;break}if(q!==l)A(c,g,c.length),f(b,a,n,a.length,d,e,h);else if(l){l=c.length-1;for(var B=a.length-1,m,v;l>=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<B--&&y(b,r(v),e),v!==q&&p(b,v,q,d,e,h),null!=q.dom&&(e=q.dom);else break;for(;l>=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={};v<z;v++){var w=m[v];null!=w&&(w=w.key,null!=w&&(x[w]=v))}m=x}null!=q&&(v=m[q.key],null==v?u(b,q,d,h,e):(v=c[v],y(b,r(v),e),v!==q&&p(b,v,q,d,e,h),v.skip=!0),null!=q.dom&&(e=q.dom))}B--}if(B<n)break}f(b,a,n,B+1,d,e,h);A(c,g,l+
|
||||
1)}else{l=c.length<a.length?c.length:a.length;for(n=n<g?n:g;n<l;n++)v=c[n],q=a[n],v===q||null==v&&null==q||(null==v?u(b,q,d,h,t(c,n+1,e)):null==q?k(v):p(b,v,q,d,t(c,n+1,e),h));c.length>l&&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<d.length;m++)t=
|
||||
d[m],null!=t&&null!=t.dom&&(null==g.dom&&(g.dom=t.dom),c+=t.domSize||1);1!==c&&(g.domSize=c)}break;default:a=g.dom=c.dom;t=g.attrs&&g.attrs.xmlns||P[g.tag]||t;"textarea"===g.tag&&(null==g.attrs&&(g.attrs={}),null!=g.text&&(g.attrs.value=g.text,g.text=void 0));f=c.attrs;n=g.attrs;q=t;if(null!=n)for(m in n)D(g,m,f&&f[m],n[m],q);if(null!=f)for(m in f)null!=n&&m in n||("className"===m&&(m="class"),"o"!==m[0]||"n"!==m[1]||w(m)?"key"!==m&&g.dom.removeAttribute(m):O(g,m,void 0));null!=g.attrs&&null!=g.attrs.contenteditable?
|
||||
b(g):null!=c.text&&null!=g.text&&""!==g.text?c.text.toString()!==g.text.toString()&&(c.dom.firstChild.nodeValue=g.text):(null!=c.text&&(c.children=[x("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=g.text&&(g.children=[x("#",void 0,void 0,g.text,void 0,void 0)]),h(a,c.children,g.children,d,null,t))}else{g.instance=x.normalize(e.call(g.state.view,g));if(g.instance===g)throw Error("A view cannot return the vnode it received as argument");null!=g.attrs&&J(g.attrs,g,d);J(g.state,g,d);null!=
|
||||
g.instance?(null==c.instance?u(a,g.instance,d,t,f):p(a,c.instance,g.instance,d,f,t),g.dom=g.instance.dom,g.domSize=g.instance.domSize):null!=c.instance?(k(c.instance),g.dom=void 0,g.domSize=0):(g.dom=c.dom,g.domSize=c.domSize)}}else k(c),u(a,g,d,t,f)}function r(a){var c=a.domSize;if(null!=c||null==a.dom){var b=z.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function t(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=
|
||||
a[c].dom)return a[c].dom;return b}function y(a,c,b){null!=b?a.insertBefore(c,b):a.appendChild(c)}function b(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function A(a,c,b){for(;c<b;c++){var n=a[c];null!=n&&(n.skip?n.skip=!1:k(n))}}function k(a){function c(){if(++n===b&&(d(a,f),m(a),a.dom)){var c=a.domSize||1;if(1<c)for(var g=
|
||||
a.dom;--c;){var e=g.nextSibling,k=e.parentNode;null!=k&&k.removeChild(e)}c=a.dom;g=c.parentNode;null!=g&&g.removeChild(c)}}var b=1,n=0,f=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var k=e.call(a.attrs.onbeforeremove,a);null!=k&&"function"===typeof k.then&&(b++,k.then(c,c))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(k=e.call(a.state.onbeforeremove,a),null!=k&&"function"===typeof k.then&&(b++,k.then(c,c)));c()}function m(a){a.attrs&&"function"===typeof a.attrs.onremove&&
|
||||
e.call(a.attrs.onremove,a);if("string"!==typeof a.tag)"function"===typeof a.state.onremove&&e.call(a.state.onremove,a),null!=a.instance&&m(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&m(b)}}function D(a,c,b,d,f){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return O(a,c,d);if("undefined"===typeof d&&"value"===c&&b!==d)a.dom.value="";else if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===z.activeElement||
|
||||
"option"===a.tag&&a.dom.parentNode===z.activeElement||"object"===typeof d)&&void 0!==d){var g=a.dom;if("xlink:"===c.slice(0,6))g.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&"object"===typeof d&&d!==a){for(var e in d)d[e]!==a[e]&&(g.style[e]=d[e]);for(e in a)e in d||(g.style[e]="")}else if(a===d&&(g.style.cssText="",a=null),null==d)g.style.cssText="";else if("string"===typeof d)g.style.cssText=d;else for(e in"string"===typeof a&&
|
||||
(g.style.cssText=""),d)g.style[e]=d[e];else if(c in g&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){e=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===e&&a.dom===z.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===z.activeElement)return}else if(null!==b&&a.dom.value===e&&a.dom===z.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===e)return}"input"===
|
||||
a.tag&&"type"===c?g.setAttribute(c,d):g[c]=d}else"boolean"===typeof d?d?g.setAttribute(c,""):g.removeAttribute(c):g.setAttribute("className"===c?"class":c,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function H(){}function O(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&
|
||||
a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&e.call(a.oninit,c);"function"===typeof a.oncreate&&b.push(e.bind(a.oncreate,c))}function J(a,c,b){"function"===typeof a.onupdate&&b.push(e.bind(a.onupdate,c))}var y=a.document;y.createDocumentFragment();var P={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},
|
||||
C,E={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof C&&C.call(a.target,a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=y.activeElement,
|
||||
f=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);m(a,a.vnodes,x.normalizeChildren(c),b,null,"http://www.w3.org/1999/xhtml"===f?void 0:f);a.vnodes=c;null!=d&&y.activeElement!==d&&d.focus();for(d=0;d<b.length;d++)b[d]()},setEventCallback:function(a){return C=a}}},F=function(a,d){function e(a){a=l.indexOf(a);-1<a&&l.splice(a,2)}function f(){if(m)throw Error("Nested m.redraw.sync() call");m=!0;for(var a=1;a<l.length;a+=2)try{l[a]()}catch(r){"undefined"!==typeof console&&console.error(r)}m=
|
||||
!1}var k=Q(a);k.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:p()});var l=[],m=!1,p=(d||S)(f);p.sync=f;return{subscribe:function(a,d){e(a);l.push(a,d)},unsubscribe:e,redraw:p,render:k.render}}(window);K.setCompletionCallback(F.redraw);w.mount=function(a){return function(d,e){if(null===e)a.render(d,[]),a.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var f=function(){a.render(d,x(e))};a.subscribe(d,
|
||||
f);f()}}}(F);var W=n,L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},f=0;f<a.length;f++){var k=a[f].split("="),l=decodeURIComponent(k[0]);k=2===k.length?decodeURIComponent(k[1]):"";"true"===k?k=!0:"false"===k&&(k=!1);var m=l.split(/\]\[?|\[/),p=d;-1<l.indexOf("[")&&m.pop();for(var u=0;u<m.length;u++){l=m[u];var r=m[u+1];r=""==r||!isNaN(parseInt(r,10));var n=u===m.length-1;""===l&&(l=m.slice(0,u).join(),null==e[l]&&(e[l]=0),l=e[l]++);null==
|
||||
p[l]&&(p[l]=n?k:r?[]:{});p=p[l]}}return d},X=function(a){function d(d){var f=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function e(a){return function(){null==m&&(m=l(function(){m=null;a()}))}}function f(a,d,f){var b=a.indexOf("?"),e=a.indexOf("#"),h=-1<b?b:-1<e?e:a.length;if(-1<b){b=L(a.slice(b+1,-1<e?e:a.length));for(var k in b)d[k]=b[k]}if(-1<e)for(k in d=L(a.slice(e+1)),d)f[k]=d[k];return a.slice(0,h)}var k="function"===typeof a.history.pushState,
|
||||
l="function"===typeof setImmediate?setImmediate:setTimeout,m,p={prefix:"#!",getPath:function(){switch(p.prefix.charAt(0)){case "#":return d("hash").slice(p.prefix.length);case "?":return d("search").slice(p.prefix.length)+d("hash");default:return d("pathname").slice(p.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,m){var b={},l={};d=f(d,b,l);if(null!=e){for(var h in e)b[h]=e[h];d=d.replace(/:([^\/]+)/g,function(a,d){delete b[d];return e[d]})}(h=E(b))&&(d+="?"+h);(l=E(l))&&(d+="#"+l);
|
||||
k?(l=m?m.state:null,h=m?m.title:null,a.onpopstate(),m&&m.replace?a.history.replaceState(l,h,p.prefix+d):a.history.pushState(l,h,p.prefix+d)):a.location.href=p.prefix+d},defineRoutes:function(d,l,m){function b(){var b=p.getPath(),e={},k=f(b,e,e),n=a.history.state;if(null!=n)for(var u in n)e[u]=n[u];for(var r in d)if(n=new RegExp("^"+r.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),n.test(k)){k.replace(n,function(){for(var a=r.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,
|
||||
1,-2),h=0;h<a.length;h++)e[a[h].replace(/:|\./g,"")]=decodeURIComponent(f[h]);l(d[r],e,b,r)});return}m(b,e)}k?a.onpopstate=e(b):"#"===p.prefix.charAt(0)&&(a.onhashchange=b);b()}};return p};w.route=function(a,d){var e=X(a),f=function(a){return a},k,l,m,p,n,r=function(a,r,h){function b(){null!=k&&d.render(a,k(x(l,m.key,m)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var u=function(){b();u=d.redraw};d.subscribe(a,b);var w=function(a){if(a!==r)e.setPath(r,
|
||||
null,{replace:!0});else throw Error("Could not resolve default route "+r);};e.defineRoutes(h,function(a,b,d){var e=n=function(a,h){e===n&&(l=null==h||"function"!==typeof h.view&&"function"!==typeof h?"div":h,m=b,p=d,n=null,k=(a.render||f).bind(a),u())};a.view||"function"===typeof a?e({},a):a.onmatch?W.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},w):e(a,"div")},w)};r.set=function(a,d,f){null!=n&&(f=f||{},f.replace=!0);n=null;e.setPath(a,d,f)};r.get=function(){return p};r.prefix=function(a){e.prefix=
|
||||
a};var w=function(a,d){d.dom.setAttribute("href",e.prefix+d.attrs.href);d.dom.onclick=function(b){b.ctrlKey||b.metaKey||b.shiftKey||2===b.which||(b.preventDefault(),b.redraw=!1,b=this.getAttribute("href"),0===b.indexOf(e.prefix)&&(b=b.slice(e.prefix.length)),r.set(b,void 0,a))}};r.link=function(a){return null==a.tag?w.bind(w,a):w({},a)};r.param=function(a){return"undefined"!==typeof m&&"undefined"!==typeof a?m[a]:m};return r}(window,F);w.withAttr=function(a,d,e){return function(f){d.call(e||this,
|
||||
a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var Y=Q(window);w.render=Y.render;w.redraw=F.redraw;w.request=K.request;w.jsonp=K.jsonp;w.parseQueryString=L;w.buildQueryString=E;w.version="1.1.3";w.vnode=x;w.PromisePolyfill=n;"undefined"!==typeof module?module.exports=w:window.m=w})();
|
||||
a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&e.call(a.oninit,c);"function"===typeof a.oncreate&&b.push(e.bind(a.oncreate,c))}function J(a,c,b){"function"===typeof a.onupdate&&b.push(e.bind(a.onupdate,c))}var z=a.document;z.createDocumentFragment();var P={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},
|
||||
C,E={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof C&&C.call(a.target,a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=z.activeElement,
|
||||
e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);h(a,a.vnodes,x.normalizeChildren(c),b,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=c;null!=d&&z.activeElement!==d&&d.focus();for(d=0;d<b.length;d++)b[d]()},setEventCallback:function(a){return C=a}}},F=function(a,d){function e(a){a=l.indexOf(a);-1<a&&l.splice(a,2)}function f(){if(h)throw Error("Nested m.redraw.sync() call");h=!0;for(var a=1;a<l.length;a+=2)try{l[a]()}catch(t){"undefined"!==typeof console&&console.error(t)}h=
|
||||
!1}var m=Q(a);m.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:p()});var l=[],h=!1,p=(d||S)(f);p.sync=f;return{subscribe:function(a,d){e(a);l.push(a,d)},unsubscribe:e,redraw:p,render:m.render}}(window);K.setCompletionCallback(F.redraw);w.mount=function(a){return function(d,e){if(null===e)a.render(d,[]),a.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var f=function(){a.render(d,x(e))};a.subscribe(d,
|
||||
f);f()}}}(F);var W=m,L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},f=0;f<a.length;f++){var m=a[f].split("="),l=decodeURIComponent(m[0]);m=2===m.length?decodeURIComponent(m[1]):"";"true"===m?m=!0:"false"===m&&(m=!1);var h=l.split(/\]\[?|\[/),p=d;-1<l.indexOf("[")&&h.pop();for(var r=0;r<h.length;r++){l=h[r];var t=h[r+1];t=""==t||!isNaN(parseInt(t,10));var y=r===h.length-1;""===l&&(l=h.slice(0,r).join(),null==e[l]&&(e[l]=0),l=e[l]++);null==
|
||||
p[l]&&(p[l]=y?m:t?[]:{});p=p[l]}}return d},X=function(a){function d(d){var e=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(a){return function(){null==h&&(h=l(function(){h=null;a()}))}}function f(a,d,e){var b=a.indexOf("?"),f=a.indexOf("#"),k=-1<b?b:-1<f?f:a.length;if(-1<b){b=L(a.slice(b+1,-1<f?f:a.length));for(var h in b)d[h]=b[h]}if(-1<f)for(h in d=L(a.slice(f+1)),d)e[h]=d[h];return a.slice(0,k)}var m="function"===typeof a.history.pushState,
|
||||
l="function"===typeof setImmediate?setImmediate:setTimeout,h,p={prefix:"#!",getPath:function(){switch(p.prefix.charAt(0)){case "#":return d("hash").slice(p.prefix.length);case "?":return d("search").slice(p.prefix.length)+d("hash");default:return d("pathname").slice(p.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,h){var b={},l={};d=f(d,b,l);if(null!=e){for(var k in e)b[k]=e[k];d=d.replace(/:([^\/]+)/g,function(a,d){delete b[d];return e[d]})}(k=E(b))&&(d+="?"+k);(l=E(l))&&(d+="#"+l);
|
||||
m?(l=h?h.state:null,k=h?h.title:null,a.onpopstate(),h&&h.replace?a.history.replaceState(l,k,p.prefix+d):a.history.pushState(l,k,p.prefix+d)):a.location.href=p.prefix+d},defineRoutes:function(d,h,l){function b(){var b=p.getPath(),e={},m=f(b,e,e),r=a.history.state;if(null!=r)for(var t in r)e[t]=r[t];for(var u in d)if(r=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),r.test(m)){m.replace(r,function(){for(var a=u.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,
|
||||
1,-2),k=0;k<a.length;k++)e[a[k].replace(/:|\./g,"")]=decodeURIComponent(f[k]);h(d[u],e,b,u)});return}l(b,e)}m?a.onpopstate=e(b):"#"===p.prefix.charAt(0)&&(a.onhashchange=b);b()}};return p};w.route=function(a,d){var e=X(a),f=function(a){return a},m,l,h,p,r,t=function(a,t,k){function b(){null!=m&&d.render(a,m(x(l,h.key,h)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var u=function(){b();u=d.redraw};d.subscribe(a,b);var w=function(a){if(a!==t)e.setPath(t,
|
||||
null,{replace:!0});else throw Error("Could not resolve default route "+t);};e.defineRoutes(k,function(a,b,d){var e=r=function(a,k){e===r&&(l=null==k||"function"!==typeof k.view&&"function"!==typeof k?"div":k,h=b,p=d,r=null,m=(a.render||f).bind(a),u())};a.view||"function"===typeof a?e({},a):a.onmatch?W.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},w):e(a,"div")},w)};t.set=function(a,d,f){null!=r&&(f=f||{},f.replace=!0);r=null;e.setPath(a,d,f)};t.get=function(){return p};t.prefix=function(a){e.prefix=
|
||||
a};var w=function(a,d){d.dom.setAttribute("href",e.prefix+d.attrs.href);d.dom.onclick=function(b){b.ctrlKey||b.metaKey||b.shiftKey||2===b.which||(b.preventDefault(),b.redraw=!1,b=this.getAttribute("href"),0===b.indexOf(e.prefix)&&(b=b.slice(e.prefix.length)),t.set(b,void 0,a))}};t.link=function(a){return null==a.tag?w.bind(w,a):w({},a)};t.param=function(a){return"undefined"!==typeof h&&"undefined"!==typeof a?h[a]:h};return t}(window,F);w.withAttr=function(a,d,e){return function(f){d.call(e||this,
|
||||
a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var Y=Q(window);w.render=Y.render;w.redraw=F.redraw;w.request=K.request;w.jsonp=K.jsonp;w.parseQueryString=L;w.buildQueryString=E;w.version="1.1.3";w.vnode=x;w.PromisePolyfill=m;"undefined"!==typeof module?module.exports=w:window.m=w})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue