Merge remote-tracking branch 'origin/rewrite' into rewrite
This commit is contained in:
commit
a2e4cf9a9f
4 changed files with 72 additions and 74 deletions
48
mithril.js
48
mithril.js
|
|
@ -82,8 +82,8 @@ hyperscript.fragment = function(attrs1, children) {
|
|||
}
|
||||
var m = hyperscript
|
||||
/** @constructor */
|
||||
var PromisePolyfill0 = function(executor) {
|
||||
if (!(this instanceof PromisePolyfill0)) throw new Error("Promise must be called with `new`")
|
||||
var PromisePolyfill = function(executor) {
|
||||
if (!(this instanceof PromisePolyfill)) throw new Error("Promise must be called with `new`")
|
||||
if (typeof executor !== "function") throw new TypeError("executor must be a function")
|
||||
var self = this, resolvers = [], rejectors = [], resolveCurrent = handler(resolvers, true), rejectCurrent = handler(rejectors, false)
|
||||
var instance = self._instance = {resolvers: resolvers, rejectors: rejectors}
|
||||
|
|
@ -124,7 +124,7 @@ var PromisePolyfill0 = function(executor) {
|
|||
}
|
||||
executeOnce(executor)
|
||||
}
|
||||
PromisePolyfill0.prototype.then = function(onFulfilled, onRejection) {
|
||||
PromisePolyfill.prototype.then = function(onFulfilled, onRejection) {
|
||||
var self = this, instance = self._instance
|
||||
function handle(callback, list, next, state) {
|
||||
list.push(function(value) {
|
||||
|
|
@ -134,22 +134,22 @@ PromisePolyfill0.prototype.then = function(onFulfilled, onRejection) {
|
|||
if (typeof instance.retry === "function" && state === instance.state) instance.retry()
|
||||
}
|
||||
var resolveNext, rejectNext
|
||||
var promise = new PromisePolyfill0(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})
|
||||
var promise = new PromisePolyfill(function(resolve, reject) {resolveNext = resolve, rejectNext = reject})
|
||||
handle(onFulfilled, instance.resolvers, resolveNext, true), handle(onRejection, instance.rejectors, rejectNext, false)
|
||||
return promise
|
||||
}
|
||||
PromisePolyfill0.prototype.catch = function(onRejection) {
|
||||
PromisePolyfill.prototype.catch = function(onRejection) {
|
||||
return this.then(null, onRejection)
|
||||
}
|
||||
PromisePolyfill0.resolve = function(value) {
|
||||
if (value instanceof PromisePolyfill0) return value
|
||||
return new PromisePolyfill0(function(resolve) {resolve(value)})
|
||||
PromisePolyfill.resolve = function(value) {
|
||||
if (value instanceof PromisePolyfill) return value
|
||||
return new PromisePolyfill(function(resolve) {resolve(value)})
|
||||
}
|
||||
PromisePolyfill0.reject = function(value) {
|
||||
return new PromisePolyfill0(function(resolve, reject) {reject(value)})
|
||||
PromisePolyfill.reject = function(value) {
|
||||
return new PromisePolyfill(function(resolve, reject) {reject(value)})
|
||||
}
|
||||
PromisePolyfill0.all = function(list) {
|
||||
return new PromisePolyfill0(function(resolve, reject) {
|
||||
PromisePolyfill.all = function(list) {
|
||||
return new PromisePolyfill(function(resolve, reject) {
|
||||
var total = list.length, count = 0, values = []
|
||||
if (list.length === 0) resolve([])
|
||||
else for (var i = 0; i < list.length; i++) {
|
||||
|
|
@ -167,18 +167,21 @@ PromisePolyfill0.all = function(list) {
|
|||
}
|
||||
})
|
||||
}
|
||||
PromisePolyfill0.race = function(list) {
|
||||
return new PromisePolyfill0(function(resolve, reject) {
|
||||
PromisePolyfill.race = function(list) {
|
||||
return new PromisePolyfill(function(resolve, reject) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i].then(resolve, reject)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (typeof Promise === "undefined") {
|
||||
if (typeof window !== "undefined") window.Promise = PromisePolyfill0
|
||||
else if (typeof global !== "undefined") global.Promise = PromisePolyfill0
|
||||
if (typeof window !== "undefined") {
|
||||
if (typeof window.Promise === "undefined") window.Promise = PromisePolyfill
|
||||
var PromisePolyfill = window.Promise
|
||||
} else if (typeof global !== "undefined") {
|
||||
if (typeof global.Promise === "undefined") global.Promise = PromisePolyfill
|
||||
var PromisePolyfill = global.Promise
|
||||
} else {
|
||||
}
|
||||
var PromisePolyfill = typeof Promise !== "undefined" ? Promise : PromisePolyfill0
|
||||
var buildQueryString = function(object) {
|
||||
if (Object.prototype.toString.call(object) !== "[object Object]") return ""
|
||||
var args = []
|
||||
|
|
@ -695,15 +698,6 @@ var coreRenderer = function($window) {
|
|||
}
|
||||
}
|
||||
}
|
||||
function once(f) {
|
||||
var called = false
|
||||
return function() {
|
||||
if (!called) {
|
||||
called = true
|
||||
f()
|
||||
}
|
||||
}
|
||||
}
|
||||
function removeNode(vnode, context) {
|
||||
var expected = 1, called = 0
|
||||
if (vnode.attrs && vnode.attrs.onbeforeremove) {
|
||||
|
|
|
|||
83
mithril.min.js
vendored
83
mithril.min.js
vendored
|
|
@ -1,41 +1,42 @@
|
|||
new function(){function w(a,c,g,d,f,l){return{tag:a,key:c,attrs:g,children:d,text:f,dom:l,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function A(a){if(null==a||"string"!==typeof a&&null==a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===I[a]){for(var c,g,d=[],f={};c=P.exec(a);){var l=c[1],k=c[2];""===l&&""!==k?g=k:"#"===l?f.id=k:"."===l?d.push(k):"["===c[3][0]&&((l=c[6])&&(l=l.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),
|
||||
"class"===c[4]?d.push(l):f[c[4]]=l||!0)}0<d.length&&(f.className=d.join(" "));I[a]=function(a,c){var d=!1,b,l,q=a.className||a["class"],y;for(y in f)a[y]=f[y];void 0!==q&&(void 0!==a["class"]&&(a["class"]=void 0,a.className=q),void 0!==f.className&&(a.className=f.className+" "+q));for(y in a)if("key"!==y){d=!0;break}c instanceof Array&&1==c.length&&null!=c[0]&&"#"===c[0].tag?l=c[0].children:b=c;return w(g||"div",a.key,d?a:void 0,b,l,void 0)}}var r;null!=arguments[1]&&("object"!==typeof arguments[1]||
|
||||
void 0!==arguments[1].tag||arguments[1]instanceof Array)?d=1:(r=arguments[1],d=2);if(arguments.length===d+1)c=arguments[d]instanceof Array?arguments[d]:[arguments[d]];else for(c=[];d<arguments.length;d++)c.push(arguments[d]);return"string"===typeof a?I[a](r||{},w.normalizeChildren(c)):w(a,r&&r.key,r||{},w.normalizeChildren(c),void 0,void 0)}function Q(a){var c=0,g=null,d="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var f=Date.now();0===c||16<=f-c?(c=
|
||||
f,a()):null===g&&(g=d(function(){g=null;a();c=Date.now()},16-(f-c)))}}w.normalize=function(a){return a instanceof Array?w("[",void 0,void 0,w.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?w("#",void 0,void 0,a,void 0,void 0):a};w.normalizeChildren=function(a){for(var c=0;c<a.length;c++)a[c]=w.normalize(a[c]);return a};var P=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,I={};A.trust=function(a){null==a&&(a="");return w("<",void 0,void 0,a,void 0,
|
||||
void 0)};A.fragment=function(a,c){return w("[",a.key,a,w.normalizeChildren(c),void 0,void 0)};var B=function(a){function c(a,b){return function n(c){var k;try{if(!b||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(k=c.then))m(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",c);for(var d=0;d<a.length;d++)a[d](c);f.length=0;l.length=0;q.state=b;q.retry=function(){n(c)}});else{if(c===d)throw new TypeError("Promise can't be resolved w/ itself");
|
||||
g(k.bind(c))}}catch(R){r(R)}}}function g(a){function b(b){return function(a){0<c++||b(a)}}var c=0,d=b(r);try{a(b(k),d)}catch(y){d(y)}}if(!(this instanceof B))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var d=this,f=[],l=[],k=c(f,!0),r=c(l,!1),q=d._instance={resolvers:f,rejectors:l},m="function"===typeof setImmediate?setImmediate:setTimeout;g(a)};B.prototype.then=function(a,c){function g(a,c,g,k){c.push(function(b){if("function"!==
|
||||
typeof a)g(b);else try{f(a(b))}catch(C){l&&l(C)}});"function"===typeof d.retry&&k===d.state&&d.retry()}var d=this._instance,f,l,k=new B(function(a,c){f=a;l=c});g(a,d.resolvers,f,!0);g(c,d.rejectors,l,!1);return k};B.prototype["catch"]=function(a){return this.then(null,a)};B.resolve=function(a){return a instanceof B?a:new B(function(c){c(a)})};B.reject=function(a){return new B(function(c,g){g(a)})};B.all=function(a){return new B(function(c,g){var d=a.length,f=0,l=[];if(0===a.length)c([]);else for(var k=
|
||||
0;k<a.length;k++)(function(k){function q(a){f++;l[k]=a;f===d&&c(l)}null==a[k]||"object"!==typeof a[k]&&"function"!==typeof a[k]||"function"!==typeof a[k].then?q(a[k]):a[k].then(q,g)})(k)})};B.race=function(a){return new B(function(c,g){for(var d=0;d<a.length;d++)a[d].then(c,g)})};"undefined"===typeof D&&("undefined"!==typeof window?window.Promise=B:"undefined"!==typeof global&&(global.Promise=B));var F="undefined"!==typeof D?D:B,G=function(a){function c(a,d){if(d instanceof Array)for(var f=0;f<d.length;f++)c(a+
|
||||
"["+f+"]",d[f]);else if("[object Object]"===Object.prototype.toString.call(d))for(f in d)c(a+"["+f+"]",d[f]);else g.push(encodeURIComponent(a)+(null!=d&&""!==d?"="+encodeURIComponent(d):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var g=[],d;for(d in a)c(d,a[d]);return g.join("&")},J=function(a,c){function g(){function b(){0===--a&&"function"===typeof u&&u()}var a=0;return function y(c){var d=c.then;c.then=function(){a++;var f=d.apply(c,arguments);f.then(b,function(c){b();
|
||||
if(0===a)throw c;});return y(f)};return c}}function d(b,a){if("string"===typeof b){var c=b;b=a||{};null==b.url&&(b.url=c)}return b}function f(b,a){if(null==a)return b;for(var c=b.match(/:[^\/]+/gi)||[],d=0;d<c.length;d++){var f=c[d].slice(1);null!=a[f]&&(b=b.replace(c[d],a[f]),delete a[f])}return b}function l(a,c){var b=G(c);if(""!==b){var d=0>a.indexOf("?")?"?":"&";a+=d+b}return a}function k(a){try{return""!==a?JSON.parse(a):null}catch(C){throw Error(a);}}function r(a){return a.responseText}function q(a,
|
||||
c){if("function"===typeof a)if(c instanceof Array)for(var b=0;b<c.length;b++)c[b]=new a(c[b]);else return new a(c);return c}var m=0,u;return{request:function(b,m){var u=g();b=d(b,m);var y=new c(function(c,d){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var g="boolean"===typeof b.useBody?b.useBody:"GET"!==b.method&&"TRACE"!==b.method;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==
|
||||
typeof b.deserialize&&(b.deserialize=k);"function"!==typeof b.extract&&(b.extract=r);b.url=f(b.url,b.data);g?b.data=b.serialize(b.data):b.url=l(b.url,b.data);var m=new a.XMLHttpRequest;m.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&&g&&m.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize===k&&m.setRequestHeader("Accept","application/json, text/*");
|
||||
b.withCredentials&&(m.withCredentials=b.withCredentials);"function"===typeof b.config&&(m=b.config(m,b)||m);m.onreadystatechange=function(){if(4===m.readyState)try{var a=b.extract!==r?b.extract(m,b):b.deserialize(b.extract(m,b));if(200<=m.status&&300>m.status||304===m.status)c(q(b.type,a));else{var f=Error(m.responseText),g;for(g in a)f[g]=a[g];d(f)}}catch(e){d(e)}};g&&null!=b.data?m.send(b.data):m.send()});return!0===b.background?y:u(y)},jsonp:function(b,k){var r=g();b=d(b,k);var u=new c(function(c,
|
||||
d){var g=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,k=a.document.createElement("script");a[g]=function(d){k.parentNode.removeChild(k);c(q(b.type,d));delete a[g]};k.onerror=function(){k.parentNode.removeChild(k);d(Error("JSONP request failed"));delete a[g]};null==b.data&&(b.data={});b.url=f(b.url,b.data);b.data[b.callbackKey||"callback"]=g;k.src=l(b.url,b.data);a.document.documentElement.appendChild(k)});return!0===b.background?u:r(u)},setCompletionCallback:function(a){u=a}}}(window,
|
||||
F),O=function(a){function c(e,h,a,b,c,d,f){for(;a<b;a++){var p=h[a];null!=p&&m(e,g(p,c,f),d)}}function g(e,h,a){var p=e.tag;null!=e.attrs&&A(e.attrs,e,h);if("string"===typeof p)switch(p){case "#":return e.dom=z.createTextNode(e.children);case "<":return d(e);case "[":var b=z.createDocumentFragment();null!=e.children&&(p=e.children,c(b,p,0,p.length,h,null,a));e.dom=b.firstChild;e.domSize=b.childNodes.length;return b;default:var g=e.tag;switch(e.tag){case "svg":a="http://www.w3.org/2000/svg";break;
|
||||
case "math":a="http://www.w3.org/1998/Math/MathML"}var m=(p=e.attrs)&&p.is,g=a?m?z.createElementNS(a,g,{is:m}):z.createElementNS(a,g):m?z.createElement(g,{is:m}):z.createElement(g);e.dom=g;if(null!=p)for(b in m=a,p)y(e,b,null,p[b],m);null!=e.attrs&&null!=e.attrs.contenteditable?u(e):(null!=e.text&&(""!==e.text?g.textContent=e.text:e.children=[w("#",void 0,void 0,e.text,void 0,void 0)]),null!=e.children&&(b=e.children,c(g,b,0,b.length,h,null,a),h=e.attrs,"select"===e.tag&&null!=h&&("value"in h&&y(e,
|
||||
"value",null,h.value,void 0),"selectedIndex"in h&&y(e,"selectedIndex",null,h.selectedIndex,void 0))));return g}else return f(e,h,a)}function d(e){var h={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(e.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",h=z.createElement(h);h.innerHTML=e.children;e.dom=h.firstChild;e.domSize=h.childNodes.length;e=z.createDocumentFragment();for(var a;a=h.firstChild;)e.appendChild(a);return e}function f(e,
|
||||
h,a){e.state||(e.state={});var b=function(){};b.prototype=e.tag;e.state=new b;b=e.tag.view;if(null!=b.reentrantLock)return N;b.reentrantLock=!0;A(e.tag,e,h);e.instance=w.normalize(b.call(e.state,e));b.reentrantLock=null;if(null!=e.instance){if(e.instance===e)throw Error("A view cannot return the vnode it received as arguments");h=g(e.instance,h,a);e.dom=e.instance.dom;e.domSize=null!=e.dom?e.instance.domSize:0;return h}e.domSize=0;return N}function l(e,a,p,d,f,l){if(a!==p&&(null!=a||null!=p))if(null==
|
||||
a)c(e,p,0,p.length,d,f,void 0);else if(null==p)b(a,0,a.length,p);else{if(a.length===p.length){for(var h=!1,t=0;t<p.length;t++)if(null!=p[t]&&null!=a[t]){h=null==p[t].key&&null==a[t].key;break}if(h){for(t=0;t<a.length;t++)a[t]!==p[t]&&(null==a[t]&&null!=p[t]?m(e,g(p[t],d,l),q(a,t+1,f)):null==p[t]?b(a,t,t+1,p):k(e,a[t],p[t],d,q(a,t+1,f),!1,l));return}}a:{if(null!=a.pool&&Math.abs(a.pool.length-p.length)<=Math.abs(a.length-p.length)&&(h=p[0]&&p[0].children&&p[0].children.length||0,Math.abs((a.pool[0]&&
|
||||
a.pool[0].children&&a.pool[0].children.length||0)-h)<=Math.abs((a[0]&&a[0].children&&a[0].children.length||0)-h))){h=!0;break a}h=!1}h&&(a=a.concat(a.pool));for(var u=t=0,v=a.length-1,y=p.length-1,C;v>=t&&y>=u;){var x=a[t],n=p[u];if(x!==n||h)if(null==x)t++;else if(null==n)u++;else if(x.key===n.key)t++,u++,k(e,x,n,d,q(a,t,f),h,l),h&&x.tag===n.tag&&m(e,r(x),f);else if(x=a[v],x!==n||h)if(null==x)v--;else if(null==n)u++;else if(x.key===n.key)k(e,x,n,d,q(a,v+1,f),h,l),(h||u<y)&&m(e,r(x),q(a,t,f)),v--,
|
||||
u++;else break;else v--,u++;else t++,u++}for(;v>=t&&y>=u;){x=a[v];n=p[y];if(x!==n||h)if(null==x)v--;else{if(null!=n)if(x.key===n.key)k(e,x,n,d,q(a,v+1,f),h,l),h&&x.tag===n.tag&&m(e,r(x),f),null!=x.dom&&(f=x.dom),v--;else{if(!C){C=a;var x=v,E={},w;for(w=0;w<x;w++){var z=C[w];null!=z&&(z=z.key,null!=z&&(E[z]=w))}C=E}null!=n&&(x=C[n.key],null!=x?(E=a[x],k(e,E,n,d,q(a,v+1,f),h,l),m(e,r(E),f),a[x].skip=!0,null!=E.dom&&(f=E.dom)):(n=g(n,d,void 0),m(e,n,f),f=n))}y--}else v--,y--;if(y<u)break}c(e,p,u,y+1,
|
||||
d,f,l);b(a,t,v+1,p)}}function k(a,h,b,c,f,q,n){var e=h.tag;if(e===b.tag){b.state=h.state;b.events=h.events;var p;var t;null!=b.attrs&&"function"===typeof b.attrs.onbeforeupdate&&(p=b.attrs.onbeforeupdate.call(b.state,b,h));"string"!==typeof b.tag&&"function"===typeof b.tag.onbeforeupdate&&(t=b.tag.onbeforeupdate.call(b.state,b,h));void 0===p&&void 0===t||p||t?p=!1:(b.dom=h.dom,b.domSize=h.domSize,b.instance=h.instance,p=!0);if(!p)if(null!=b.attrs&&M(b.attrs,b,c,q),"string"===typeof e)switch(e){case "#":h.children.toString()!==
|
||||
b.children.toString()&&(h.dom.nodeValue=b.children);b.dom=h.dom;break;case "<":h.children!==b.children?(r(h),m(a,d(b),f)):(b.dom=h.dom,b.domSize=h.domSize);break;case "[":l(a,h.children,b.children,c,f,n);h=0;c=b.children;b.dom=null;if(null!=c){for(var v=0;v<c.length;v++)a=c[v],null!=a&&null!=a.dom&&(null==b.dom&&(b.dom=a.dom),h+=a.domSize||1);1!==h&&(b.domSize=h)}break;default:a=n;f=b.dom=h.dom;switch(b.tag){case "svg":a="http://www.w3.org/2000/svg";break;case "math":a="http://www.w3.org/1998/Math/MathML"}"textarea"===
|
||||
b.tag&&(null==b.attrs&&(b.attrs={}),null!=b.text&&(b.attrs.value=b.text,b.text=void 0));q=h.attrs;n=b.attrs;e=a;if(null!=n)for(v in n)y(b,v,q&&q[v],n[v],e);if(null!=q)for(v in q)null!=n&&v in n||("className"===v&&(v="class"),"o"!==v[0]||"n"!==v[1]||L(v)?"key"!==v&&b.dom.removeAttribute(v):B(b,v,void 0));null!=b.attrs&&null!=b.attrs.contenteditable?u(b):null!=h.text&&null!=b.text&&""!==b.text?h.text.toString()!==b.text.toString()&&(h.dom.firstChild.nodeValue=b.text):(null!=h.text&&(h.children=[w("#",
|
||||
void 0,void 0,h.text,void 0,h.dom.firstChild)]),null!=b.text&&(b.children=[w("#",void 0,void 0,b.text,void 0,void 0)]),l(f,h.children,b.children,c,null,a))}else b.instance=w.normalize(b.tag.view.call(b.state,b)),M(b.tag,b,c,q),null!=b.instance?(null==h.instance?m(a,g(b.instance,c,n),f):k(a,h.instance,b.instance,c,f,q,n),b.dom=b.instance.dom,b.domSize=b.instance.domSize):null!=h.instance?(C(h.instance,null),b.dom=void 0,b.domSize=0):(b.dom=h.dom,b.domSize=h.domSize)}else C(h,null),m(a,g(b,c,n),f)}
|
||||
function r(a){var b=a.domSize;if(null!=b||null==a.dom){var e=z.createDocumentFragment();if(0<b){for(a=a.dom;--b;)e.appendChild(a.nextSibling);e.insertBefore(a,e.firstChild)}return e}return a.dom}function q(a,b,c){for(;b<a.length;b++)if(null!=a[b]&&null!=a[b].dom)return a[b].dom;return c}function m(a,b,c){c&&c.parentNode?a.insertBefore(b,c):a.appendChild(b)}function u(a){var b=a.children;if(null!=b&&1===b.length&&"<"===b[0].tag)b=b[0].children,a.dom.innerHTML!==b&&(a.dom.innerHTML=b);else if(null!=
|
||||
a.text||null!=b&&0!==b.length)throw Error("Child node of a contenteditable must be trusted");}function b(a,b,c,d){for(;b<c;b++){var e=a[b];null!=e&&(e.skip?e.skip=!1:C(e,d))}}function C(a,b){function e(){if(++h===c&&(n(a),a.dom)){var e=a.domSize||1;if(1<e)for(var d=a.dom;--e;){var f=d.nextSibling,g=f.parentNode;null!=g&&g.removeChild(f)}e=a.dom;d=e.parentNode;null!=d&&d.removeChild(e);if(e=null!=b&&null==a.domSize)e=a.attrs,e=!(null!=e&&(e.oncreate||e.onupdate||e.onbeforeremove||e.onremove));e&&"string"===
|
||||
typeof a.tag&&(b.pool?b.pool.push(a):b.pool=[a])}}var c=1,h=0;if(a.attrs&&a.attrs.onbeforeremove){var d=a.attrs.onbeforeremove.call(a.state,a);null!=d&&"function"===typeof d.then&&(c++,d.then(e,e))}"string"!==typeof a.tag&&a.tag.onbeforeremove&&(d=a.tag.onbeforeremove.call(a.state,a),null!=d&&"function"===typeof d.then&&(c++,d.then(e,e)));e()}function n(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);"string"!==typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)n(a.instance);
|
||||
else if(a=a.children,a instanceof Array)for(var b=0;b<a.length;b++){var e=a[b];null!=e&&n(e)}}function y(a,b,c,d,f){var e=a.dom;if("key"!==b&&"is"!==b&&(c!==d||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===z.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&!L(b)){var h=b.indexOf(":");if(-1<h&&"xlink"===b.substr(0,h))e.setAttributeNS("http://www.w3.org/1999/xlink",b.slice(h+1),d);else if("o"===b[0]&&"n"===b[1]&&"function"===typeof d)B(a,b,d);else if("style"===
|
||||
b)if(a=c,a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else{"string"===typeof a&&(e.style.cssText="");for(var g in d)e.style[g]=d[g];if(null!=a&&"string"!==typeof a)for(g in a)g in d||(e.style[g]="")}else b in e&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&"value"===b&&a.dom.value===d&&a.dom===z.activeElement||"select"===a.tag&&"value"===b&&a.dom.value===
|
||||
d&&a.dom===z.activeElement||"option"===a.tag&&"value"===b&&a.dom.value===d||(e[b]=d):"boolean"===typeof d?d?e.setAttribute(b,""):e.removeAttribute(b):e.setAttribute("className"===b?"class":b,d)}}function L(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function B(a,b,c){var e=a.dom,d="function"!==typeof D?c:function(a){var b=c.call(e,a);D.call(e,a);return b};if(b in e)e[b]="function"===typeof c?d:null;else{var f=b.slice(2);void 0===
|
||||
a.events&&(a.events={});a.events[b]!==d&&(null!=a.events[b]&&e.removeEventListener(f,a.events[b],!1),"function"===typeof c&&(a.events[b]=d,e.addEventListener(f,a.events[b],!1)))}}function A(a,b,c){"function"===typeof a.oninit&&a.oninit.call(b.state,b);"function"===typeof a.oncreate&&c.push(a.oncreate.bind(b.state,b))}function M(a,b,c,d){d?A(a,b,c):"function"===typeof a.onupdate&&c.push(a.onupdate.bind(b.state,b))}var z=a.document,N=z.createDocumentFragment(),D;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");
|
||||
var c=[],d=z.activeElement;null==a.vnodes&&(a.textContent="");b instanceof Array||(b=[b]);l(a,a.vnodes,w.normalizeChildren(b),c,null,void 0);a.vnodes=b;for(var e=0;e<c.length;e++)c[e]();z.activeElement!==d&&d.focus()},setEventCallback:function(a){return D=a}}},H=function(a){function c(a){a=d.indexOf(a);-1<a&&d.splice(a,2)}function g(){for(var a=1;a<d.length;a+=2)d[a]()}a=O(a);a.setEventCallback(function(a){!1!==a.redraw&&g()});var d=[];return{subscribe:function(a,g){c(a);d.push(a,Q(g))},unsubscribe:c,
|
||||
redraw:g,render:a.render}}(window);J.setCompletionCallback(H.redraw);A.mount=function(a){return function(c,g){if(null===g)a.render(c,[]),a.unsubscribe(c);else{if(null==g.view)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(c,function(){a.render(c,w(g))});a.redraw()}}}(H);var D=F,K=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var c={},g={},d=0;d<a.length;d++){var f=a[d].split("="),l=decodeURIComponent(f[0]),f=2===
|
||||
f.length?decodeURIComponent(f[1]):"";"true"===f?f=!0:"false"===f&&(f=!1);var k=l.split(/\]\[?|\[/),r=c;-1<l.indexOf("[")&&k.pop();for(var q=0;q<k.length;q++){var l=k[q],m=k[q+1],m=""==m||!isNaN(parseInt(m,10)),u=q===k.length-1;""===l&&(l=k.slice(0,q).join(),null==g[l]&&(g[l]=0),l=g[l]++);null==r[l]&&(r[l]=u?f:m?[]:{});r=r[l]}}return c},S=function(a){function c(c){var d=a.location[c].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===c&&"/"!==d[0]&&(d="/"+d);return d}function g(a){return function(){null==
|
||||
k&&(k=l(function(){k=null;a()}))}}function d(a,c,d){var b=a.indexOf("?"),f=a.indexOf("#"),g=-1<b?b:-1<f?f:a.length;if(-1<b){var b=K(a.slice(b+1,-1<f?f:a.length)),k;for(k in b)c[k]=b[k]}if(-1<f)for(k in c=K(a.slice(f+1)),c)d[k]=c[k];return a.slice(0,g)}var f="function"===typeof a.history.pushState,l="function"===typeof setImmediate?setImmediate:setTimeout,k,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return c("hash").slice(r.prefix.length);case "?":return c("search").slice(r.prefix.length)+
|
||||
c("hash");default:return c("pathname").slice(r.prefix.length)+c("search")+c("hash")}},setPath:function(c,g,k){var b={},l={};c=d(c,b,l);if(null!=g){for(var n in g)b[n]=g[n];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return g[c]})}(n=G(b))&&(c+="?"+n);(l=G(l))&&(c+="#"+l);f?(l=k?k.state:null,n=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(l,n,r.prefix+c):a.history.pushState(l,n,r.prefix+c)):a.location.href=r.prefix+c},defineRoutes:function(c,k,l){function b(){var b=r.getPath(),
|
||||
f={},g=d(b,f,f),m=a.history.state;if(null!=m)for(var q in m)f[q]=m[q];for(var u in c)if(m=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),m.test(g)){g.replace(m,function(){for(var a=u.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0;g<a.length;g++)f[a[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);k(c[u],f,b,u)});return}l(b,f)}f?a.onpopstate=g(b):"#"===r.prefix.charAt(0)&&(a.onhashchange=b);b()}};return r};A.route=function(a,c){var g=S(a),d=function(a){return a},
|
||||
f,l,k,r,q,m=function(a,b,m){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var n=function(){null!=f&&c.render(a,f(w(l,k.key,k)))},u=function(){g.setPath(b,null,{replace:!0})};g.defineRoutes(m,function(a,b,c){var g=q=function(a,m){g===q&&(l=null!=m&&"function"===typeof m.view?m:"div",k=b,r=c,q=null,f=(a.render||d).bind(a),n())};a.view?g({},a):a.onmatch?D.resolve(a.onmatch(b,c)).then(function(b){g(a,b)},u):g(a,"div")},u);c.subscribe(a,n)};m.set=function(a,
|
||||
b,c){null!=q&&(c={replace:!0});q=null;g.setPath(a,b,c)};m.get=function(){return r};m.prefix=function(a){g.prefix=a};m.link=function(a){a.dom.setAttribute("href",g.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(g.prefix)&&(a=a.slice(g.prefix.length)),m.set(a,void 0,void 0))}};return m}(window,H);A.withAttr=function(a,c,g){return function(d){return c.call(g||this,a in d.currentTarget?
|
||||
d.currentTarget[a]:d.currentTarget.getAttribute(a))}};F=O(window);A.render=F.render;A.redraw=H.redraw;A.request=J.request;A.jsonp=J.jsonp;A.parseQueryString=K;A.buildQueryString=G;A.version="1.0.0-rc.6";A.vnode=w;"undefined"!==typeof module?module.exports=A:window.m=A};
|
||||
new function(){function w(a,c,g,d,f,l){return{tag:a,key:c,attrs:g,children:d,text:f,dom:l,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function A(a){if(null==a||"string"!==typeof a&&null==a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===G[a]){for(var c,g,d=[],f={};c=N.exec(a);){var l=c[1],k=c[2];""===l&&""!==k?g=k:"#"===l?f.id=k:"."===l?d.push(k):"["===c[3][0]&&((l=c[6])&&(l=l.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),
|
||||
"class"===c[4]?d.push(l):f[c[4]]=l||!0)}0<d.length&&(f.className=d.join(" "));G[a]=function(a,c){var d=!1,b,l,q=a.className||a["class"],z;for(z in f)a[z]=f[z];void 0!==q&&(void 0!==a["class"]&&(a["class"]=void 0,a.className=q),void 0!==f.className&&(a.className=f.className+" "+q));for(z in a)if("key"!==z){d=!0;break}c instanceof Array&&1==c.length&&null!=c[0]&&"#"===c[0].tag?l=c[0].children:b=c;return w(g||"div",a.key,d?a:void 0,b,l,void 0)}}var r;null!=arguments[1]&&("object"!==typeof arguments[1]||
|
||||
void 0!==arguments[1].tag||arguments[1]instanceof Array)?d=1:(r=arguments[1],d=2);if(arguments.length===d+1)c=arguments[d]instanceof Array?arguments[d]:[arguments[d]];else for(c=[];d<arguments.length;d++)c.push(arguments[d]);return"string"===typeof a?G[a](r||{},w.normalizeChildren(c)):w(a,r&&r.key,r||{},w.normalizeChildren(c),void 0,void 0)}function O(a){var c=0,g=null,d="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var f=Date.now();0===c||16<=f-c?(c=
|
||||
f,a()):null===g&&(g=d(function(){g=null;a();c=Date.now()},16-(f-c)))}}w.normalize=function(a){return a instanceof Array?w("[",void 0,void 0,w.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?w("#",void 0,void 0,a,void 0,void 0):a};w.normalizeChildren=function(a){for(var c=0;c<a.length;c++)a[c]=w.normalize(a[c]);return a};var N=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,G={};A.trust=function(a){null==a&&(a="");return w("<",void 0,void 0,a,void 0,
|
||||
void 0)};A.fragment=function(a,c){return w("[",a.key,a,w.normalizeChildren(c),void 0,void 0)};var x=function(a){function c(a,b){return function n(c){var k;try{if(!b||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(k=c.then))m(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",c);for(var d=0;d<a.length;d++)a[d](c);f.length=0;l.length=0;q.state=b;q.retry=function(){n(c)}});else{if(c===d)throw new TypeError("Promise can't be resolved w/ itself");
|
||||
g(k.bind(c))}}catch(P){r(P)}}}function g(a){function b(b){return function(a){0<c++||b(a)}}var c=0,d=b(r);try{a(b(k),d)}catch(z){d(z)}}if(!(this instanceof x))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var d=this,f=[],l=[],k=c(f,!0),r=c(l,!1),q=d._instance={resolvers:f,rejectors:l},m="function"===typeof setImmediate?setImmediate:setTimeout;g(a)};x.prototype.then=function(a,c){function g(a,c,g,k){c.push(function(b){if("function"!==
|
||||
typeof a)g(b);else try{f(a(b))}catch(C){l&&l(C)}});"function"===typeof d.retry&&k===d.state&&d.retry()}var d=this._instance,f,l,k=new x(function(a,c){f=a;l=c});g(a,d.resolvers,f,!0);g(c,d.rejectors,l,!1);return k};x.prototype["catch"]=function(a){return this.then(null,a)};x.resolve=function(a){return a instanceof x?a:new x(function(c){c(a)})};x.reject=function(a){return new x(function(c,g){g(a)})};x.all=function(a){return new x(function(c,g){var d=a.length,f=0,l=[];if(0===a.length)c([]);else for(var k=
|
||||
0;k<a.length;k++)(function(k){function q(a){f++;l[k]=a;f===d&&c(l)}null==a[k]||"object"!==typeof a[k]&&"function"!==typeof a[k]||"function"!==typeof a[k].then?q(a[k]):a[k].then(q,g)})(k)})};x.race=function(a){return new x(function(c,g){for(var d=0;d<a.length;d++)a[d].then(c,g)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=x),x=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=x),x=global.Promise);var D=function(a){function c(a,
|
||||
d){if(d instanceof Array)for(var f=0;f<d.length;f++)c(a+"["+f+"]",d[f]);else if("[object Object]"===Object.prototype.toString.call(d))for(f in d)c(a+"["+f+"]",d[f]);else g.push(encodeURIComponent(a)+(null!=d&&""!==d?"="+encodeURIComponent(d):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var g=[],d;for(d in a)c(d,a[d]);return g.join("&")},I=function(a,c){function g(){function b(){0===--a&&"function"===typeof u&&u()}var a=0;return function z(c){var d=c.then;c.then=function(){a++;
|
||||
var f=d.apply(c,arguments);f.then(b,function(c){b();if(0===a)throw c;});return z(f)};return c}}function d(b,a){if("string"===typeof b){var c=b;b=a||{};null==b.url&&(b.url=c)}return b}function f(b,a){if(null==a)return b;for(var c=b.match(/:[^\/]+/gi)||[],d=0;d<c.length;d++){var f=c[d].slice(1);null!=a[f]&&(b=b.replace(c[d],a[f]),delete a[f])}return b}function l(a,c){var b=D(c);if(""!==b){var d=0>a.indexOf("?")?"?":"&";a+=d+b}return a}function k(a){try{return""!==a?JSON.parse(a):null}catch(C){throw Error(a);
|
||||
}}function r(a){return a.responseText}function q(a,c){if("function"===typeof a)if(c instanceof Array)for(var b=0;b<c.length;b++)c[b]=new a(c[b]);else return new a(c);return c}var m=0,u;return{request:function(b,m){var u=g();b=d(b,m);var z=new c(function(c,d){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var g="boolean"===typeof b.useBody?b.useBody:"GET"!==b.method&&"TRACE"!==b.method;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?
|
||||
function(a){return a}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=k);"function"!==typeof b.extract&&(b.extract=r);b.url=f(b.url,b.data);g?b.data=b.serialize(b.data):b.url=l(b.url,b.data);var m=new a.XMLHttpRequest;m.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&&g&&m.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize===
|
||||
k&&m.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(m.withCredentials=b.withCredentials);"function"===typeof b.config&&(m=b.config(m,b)||m);m.onreadystatechange=function(){if(4===m.readyState)try{var a=b.extract!==r?b.extract(m,b):b.deserialize(b.extract(m,b));if(200<=m.status&&300>m.status||304===m.status)c(q(b.type,a));else{var f=Error(m.responseText),g;for(g in a)f[g]=a[g];d(f)}}catch(e){d(e)}};g&&null!=b.data?m.send(b.data):m.send()});return!0===b.background?z:u(z)},
|
||||
jsonp:function(b,k){var r=g();b=d(b,k);var u=new c(function(c,d){var g=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,k=a.document.createElement("script");a[g]=function(d){k.parentNode.removeChild(k);c(q(b.type,d));delete a[g]};k.onerror=function(){k.parentNode.removeChild(k);d(Error("JSONP request failed"));delete a[g]};null==b.data&&(b.data={});b.url=f(b.url,b.data);b.data[b.callbackKey||"callback"]=g;k.src=l(b.url,b.data);a.document.documentElement.appendChild(k)});return!0===
|
||||
b.background?u:r(u)},setCompletionCallback:function(a){u=a}}}(window,x),M=function(a){function c(e,h,a,b,c,d,f){for(;a<b;a++){var p=h[a];null!=p&&m(e,g(p,c,f),d)}}function g(e,h,a){var p=e.tag;null!=e.attrs&&H(e.attrs,e,h);if("string"===typeof p)switch(p){case "#":return e.dom=B.createTextNode(e.children);case "<":return d(e);case "[":var b=B.createDocumentFragment();null!=e.children&&(p=e.children,c(b,p,0,p.length,h,null,a));e.dom=b.firstChild;e.domSize=b.childNodes.length;return b;default:var g=
|
||||
e.tag;switch(e.tag){case "svg":a="http://www.w3.org/2000/svg";break;case "math":a="http://www.w3.org/1998/Math/MathML"}var m=(p=e.attrs)&&p.is,g=a?m?B.createElementNS(a,g,{is:m}):B.createElementNS(a,g):m?B.createElement(g,{is:m}):B.createElement(g);e.dom=g;if(null!=p)for(b in m=a,p)z(e,b,null,p[b],m);null!=e.attrs&&null!=e.attrs.contenteditable?u(e):(null!=e.text&&(""!==e.text?g.textContent=e.text:e.children=[w("#",void 0,void 0,e.text,void 0,void 0)]),null!=e.children&&(b=e.children,c(g,b,0,b.length,
|
||||
h,null,a),h=e.attrs,"select"===e.tag&&null!=h&&("value"in h&&z(e,"value",null,h.value,void 0),"selectedIndex"in h&&z(e,"selectedIndex",null,h.selectedIndex,void 0))));return g}else return f(e,h,a)}function d(e){var h={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(e.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",h=B.createElement(h);h.innerHTML=e.children;e.dom=h.firstChild;e.domSize=h.childNodes.length;e=B.createDocumentFragment();
|
||||
for(var a;a=h.firstChild;)e.appendChild(a);return e}function f(e,h,a){e.state||(e.state={});var b=function(){};b.prototype=e.tag;e.state=new b;b=e.tag.view;if(null!=b.reentrantLock)return L;b.reentrantLock=!0;H(e.tag,e,h);e.instance=w.normalize(b.call(e.state,e));b.reentrantLock=null;if(null!=e.instance){if(e.instance===e)throw Error("A view cannot return the vnode it received as arguments");h=g(e.instance,h,a);e.dom=e.instance.dom;e.domSize=null!=e.dom?e.instance.domSize:0;return h}e.domSize=0;return L}
|
||||
function l(e,a,p,d,f,l){if(a!==p&&(null!=a||null!=p))if(null==a)c(e,p,0,p.length,d,f,void 0);else if(null==p)b(a,0,a.length,p);else{if(a.length===p.length){for(var h=!1,t=0;t<p.length;t++)if(null!=p[t]&&null!=a[t]){h=null==p[t].key&&null==a[t].key;break}if(h){for(t=0;t<a.length;t++)a[t]!==p[t]&&(null==a[t]&&null!=p[t]?m(e,g(p[t],d,l),q(a,t+1,f)):null==p[t]?b(a,t,t+1,p):k(e,a[t],p[t],d,q(a,t+1,f),!1,l));return}}a:{if(null!=a.pool&&Math.abs(a.pool.length-p.length)<=Math.abs(a.length-p.length)&&(h=p[0]&&
|
||||
p[0].children&&p[0].children.length||0,Math.abs((a.pool[0]&&a.pool[0].children&&a.pool[0].children.length||0)-h)<=Math.abs((a[0]&&a[0].children&&a[0].children.length||0)-h))){h=!0;break a}h=!1}h&&(a=a.concat(a.pool));for(var u=t=0,v=a.length-1,z=p.length-1,C;v>=t&&z>=u;){var y=a[t],n=p[u];if(y!==n||h)if(null==y)t++;else if(null==n)u++;else if(y.key===n.key)t++,u++,k(e,y,n,d,q(a,t,f),h,l),h&&y.tag===n.tag&&m(e,r(y),f);else if(y=a[v],y!==n||h)if(null==y)v--;else if(null==n)u++;else if(y.key===n.key)k(e,
|
||||
y,n,d,q(a,v+1,f),h,l),(h||u<z)&&m(e,r(y),q(a,t,f)),v--,u++;else break;else v--,u++;else t++,u++}for(;v>=t&&z>=u;){y=a[v];n=p[z];if(y!==n||h)if(null==y)v--;else{if(null!=n)if(y.key===n.key)k(e,y,n,d,q(a,v+1,f),h,l),h&&y.tag===n.tag&&m(e,r(y),f),null!=y.dom&&(f=y.dom),v--;else{if(!C){C=a;var y=v,E={},w;for(w=0;w<y;w++){var x=C[w];null!=x&&(x=x.key,null!=x&&(E[x]=w))}C=E}null!=n&&(y=C[n.key],null!=y?(E=a[y],k(e,E,n,d,q(a,v+1,f),h,l),m(e,r(E),f),a[y].skip=!0,null!=E.dom&&(f=E.dom)):(n=g(n,d,void 0),m(e,
|
||||
n,f),f=n))}z--}else v--,z--;if(z<u)break}c(e,p,u,z+1,d,f,l);b(a,t,v+1,p)}}function k(a,h,b,c,f,q,n){var e=h.tag;if(e===b.tag){b.state=h.state;b.events=h.events;var p;var t;null!=b.attrs&&"function"===typeof b.attrs.onbeforeupdate&&(p=b.attrs.onbeforeupdate.call(b.state,b,h));"string"!==typeof b.tag&&"function"===typeof b.tag.onbeforeupdate&&(t=b.tag.onbeforeupdate.call(b.state,b,h));void 0===p&&void 0===t||p||t?p=!1:(b.dom=h.dom,b.domSize=h.domSize,b.instance=h.instance,p=!0);if(!p)if(null!=b.attrs&&
|
||||
K(b.attrs,b,c,q),"string"===typeof e)switch(e){case "#":h.children.toString()!==b.children.toString()&&(h.dom.nodeValue=b.children);b.dom=h.dom;break;case "<":h.children!==b.children?(r(h),m(a,d(b),f)):(b.dom=h.dom,b.domSize=h.domSize);break;case "[":l(a,h.children,b.children,c,f,n);h=0;c=b.children;b.dom=null;if(null!=c){for(var v=0;v<c.length;v++)a=c[v],null!=a&&null!=a.dom&&(null==b.dom&&(b.dom=a.dom),h+=a.domSize||1);1!==h&&(b.domSize=h)}break;default:a=n;f=b.dom=h.dom;switch(b.tag){case "svg":a=
|
||||
"http://www.w3.org/2000/svg";break;case "math":a="http://www.w3.org/1998/Math/MathML"}"textarea"===b.tag&&(null==b.attrs&&(b.attrs={}),null!=b.text&&(b.attrs.value=b.text,b.text=void 0));q=h.attrs;n=b.attrs;e=a;if(null!=n)for(v in n)z(b,v,q&&q[v],n[v],e);if(null!=q)for(v in q)null!=n&&v in n||("className"===v&&(v="class"),"o"!==v[0]||"n"!==v[1]||x(v)?"key"!==v&&b.dom.removeAttribute(v):A(b,v,void 0));null!=b.attrs&&null!=b.attrs.contenteditable?u(b):null!=h.text&&null!=b.text&&""!==b.text?h.text.toString()!==
|
||||
b.text.toString()&&(h.dom.firstChild.nodeValue=b.text):(null!=h.text&&(h.children=[w("#",void 0,void 0,h.text,void 0,h.dom.firstChild)]),null!=b.text&&(b.children=[w("#",void 0,void 0,b.text,void 0,void 0)]),l(f,h.children,b.children,c,null,a))}else b.instance=w.normalize(b.tag.view.call(b.state,b)),K(b.tag,b,c,q),null!=b.instance?(null==h.instance?m(a,g(b.instance,c,n),f):k(a,h.instance,b.instance,c,f,q,n),b.dom=b.instance.dom,b.domSize=b.instance.domSize):null!=h.instance?(C(h.instance,null),b.dom=
|
||||
void 0,b.domSize=0):(b.dom=h.dom,b.domSize=h.domSize)}else C(h,null),m(a,g(b,c,n),f)}function r(a){var b=a.domSize;if(null!=b||null==a.dom){var e=B.createDocumentFragment();if(0<b){for(a=a.dom;--b;)e.appendChild(a.nextSibling);e.insertBefore(a,e.firstChild)}return e}return a.dom}function q(a,b,c){for(;b<a.length;b++)if(null!=a[b]&&null!=a[b].dom)return a[b].dom;return c}function m(a,b,c){c&&c.parentNode?a.insertBefore(b,c):a.appendChild(b)}function u(a){var b=a.children;if(null!=b&&1===b.length&&
|
||||
"<"===b[0].tag)b=b[0].children,a.dom.innerHTML!==b&&(a.dom.innerHTML=b);else if(null!=a.text||null!=b&&0!==b.length)throw Error("Child node of a contenteditable must be trusted");}function b(a,b,c,d){for(;b<c;b++){var e=a[b];null!=e&&(e.skip?e.skip=!1:C(e,d))}}function C(a,b){function e(){if(++h===c&&(n(a),a.dom)){var e=a.domSize||1;if(1<e)for(var d=a.dom;--e;){var f=d.nextSibling,g=f.parentNode;null!=g&&g.removeChild(f)}e=a.dom;d=e.parentNode;null!=d&&d.removeChild(e);if(e=null!=b&&null==a.domSize)e=
|
||||
a.attrs,e=!(null!=e&&(e.oncreate||e.onupdate||e.onbeforeremove||e.onremove));e&&"string"===typeof a.tag&&(b.pool?b.pool.push(a):b.pool=[a])}}var c=1,h=0;if(a.attrs&&a.attrs.onbeforeremove){var d=a.attrs.onbeforeremove.call(a.state,a);null!=d&&"function"===typeof d.then&&(c++,d.then(e,e))}"string"!==typeof a.tag&&a.tag.onbeforeremove&&(d=a.tag.onbeforeremove.call(a.state,a),null!=d&&"function"===typeof d.then&&(c++,d.then(e,e)));e()}function n(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,
|
||||
a);"string"!==typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)n(a.instance);else if(a=a.children,a instanceof Array)for(var b=0;b<a.length;b++){var e=a[b];null!=e&&n(e)}}function z(a,b,c,d,f){var e=a.dom;if("key"!==b&&"is"!==b&&(c!==d||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===B.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&!x(b)){var h=b.indexOf(":");if(-1<h&&"xlink"===b.substr(0,h))e.setAttributeNS("http://www.w3.org/1999/xlink",
|
||||
b.slice(h+1),d);else if("o"===b[0]&&"n"===b[1]&&"function"===typeof d)A(a,b,d);else if("style"===b)if(a=c,a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else{"string"===typeof a&&(e.style.cssText="");for(var g in d)e.style[g]=d[g];if(null!=a&&"string"!==typeof a)for(g in a)g in d||(e.style[g]="")}else b in e&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&
|
||||
"value"===b&&a.dom.value===d&&a.dom===B.activeElement||"select"===a.tag&&"value"===b&&a.dom.value===d&&a.dom===B.activeElement||"option"===a.tag&&"value"===b&&a.dom.value===d||(e[b]=d):"boolean"===typeof d?d?e.setAttribute(b,""):e.removeAttribute(b):e.setAttribute("className"===b?"class":b,d)}}function x(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function A(a,b,c){var e=a.dom,d="function"!==typeof D?c:function(a){var b=c.call(e,
|
||||
a);D.call(e,a);return b};if(b in e)e[b]="function"===typeof c?d:null;else{var f=b.slice(2);void 0===a.events&&(a.events={});a.events[b]!==d&&(null!=a.events[b]&&e.removeEventListener(f,a.events[b],!1),"function"===typeof c&&(a.events[b]=d,e.addEventListener(f,a.events[b],!1)))}}function H(a,b,c){"function"===typeof a.oninit&&a.oninit.call(b.state,b);"function"===typeof a.oncreate&&c.push(a.oncreate.bind(b.state,b))}function K(a,b,c,d){d?H(a,b,c):"function"===typeof a.onupdate&&c.push(a.onupdate.bind(b.state,
|
||||
b))}var B=a.document,L=B.createDocumentFragment(),D;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=B.activeElement;null==a.vnodes&&(a.textContent="");b instanceof Array||(b=[b]);l(a,a.vnodes,w.normalizeChildren(b),c,null,void 0);a.vnodes=b;for(var e=0;e<c.length;e++)c[e]();B.activeElement!==d&&d.focus()},setEventCallback:function(a){return D=a}}},F=function(a){function c(a){a=d.indexOf(a);-1<a&&d.splice(a,
|
||||
2)}function g(){for(var a=1;a<d.length;a+=2)d[a]()}a=M(a);a.setEventCallback(function(a){!1!==a.redraw&&g()});var d=[];return{subscribe:function(a,g){c(a);d.push(a,O(g))},unsubscribe:c,redraw:g,render:a.render}}(window);I.setCompletionCallback(F.redraw);A.mount=function(a){return function(c,g){if(null===g)a.render(c,[]),a.unsubscribe(c);else{if(null==g.view)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(c,function(){a.render(c,w(g))});a.redraw()}}}(F);var Q=
|
||||
x,J=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var c={},g={},d=0;d<a.length;d++){var f=a[d].split("="),l=decodeURIComponent(f[0]),f=2===f.length?decodeURIComponent(f[1]):"";"true"===f?f=!0:"false"===f&&(f=!1);var k=l.split(/\]\[?|\[/),r=c;-1<l.indexOf("[")&&k.pop();for(var q=0;q<k.length;q++){var l=k[q],m=k[q+1],m=""==m||!isNaN(parseInt(m,10)),u=q===k.length-1;""===l&&(l=k.slice(0,q).join(),null==g[l]&&(g[l]=0),l=g[l]++);null==r[l]&&(r[l]=u?f:m?[]:
|
||||
{});r=r[l]}}return c},R=function(a){function c(c){var d=a.location[c].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===c&&"/"!==d[0]&&(d="/"+d);return d}function g(a){return function(){null==k&&(k=l(function(){k=null;a()}))}}function d(a,c,d){var b=a.indexOf("?"),f=a.indexOf("#"),g=-1<b?b:-1<f?f:a.length;if(-1<b){var b=J(a.slice(b+1,-1<f?f:a.length)),k;for(k in b)c[k]=b[k]}if(-1<f)for(k in c=J(a.slice(f+1)),c)d[k]=c[k];return a.slice(0,g)}var f="function"===typeof a.history.pushState,
|
||||
l="function"===typeof setImmediate?setImmediate:setTimeout,k,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return c("hash").slice(r.prefix.length);case "?":return c("search").slice(r.prefix.length)+c("hash");default:return c("pathname").slice(r.prefix.length)+c("search")+c("hash")}},setPath:function(c,g,k){var b={},l={};c=d(c,b,l);if(null!=g){for(var n in g)b[n]=g[n];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return g[c]})}(n=D(b))&&(c+="?"+n);(l=D(l))&&(c+="#"+l);
|
||||
f?(l=k?k.state:null,n=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(l,n,r.prefix+c):a.history.pushState(l,n,r.prefix+c)):a.location.href=r.prefix+c},defineRoutes:function(c,k,l){function b(){var b=r.getPath(),f={},g=d(b,f,f),m=a.history.state;if(null!=m)for(var q in m)f[q]=m[q];for(var u in c)if(m=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),m.test(g)){g.replace(m,function(){for(var a=u.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,
|
||||
1,-2),g=0;g<a.length;g++)f[a[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);k(c[u],f,b,u)});return}l(b,f)}f?a.onpopstate=g(b):"#"===r.prefix.charAt(0)&&(a.onhashchange=b);b()}};return r};A.route=function(a,c){var g=R(a),d=function(a){return a},f,l,k,r,q,m=function(a,b,m){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var n=function(){null!=f&&c.render(a,f(w(l,k.key,k)))},u=function(){g.setPath(b,null,{replace:!0})};g.defineRoutes(m,function(a,b,c){var g=
|
||||
q=function(a,m){g===q&&(l=null!=m&&"function"===typeof m.view?m:"div",k=b,r=c,q=null,f=(a.render||d).bind(a),n())};a.view?g({},a):a.onmatch?Q.resolve(a.onmatch(b,c)).then(function(b){g(a,b)},u):g(a,"div")},u);c.subscribe(a,n)};m.set=function(a,b,c){null!=q&&(c={replace:!0});q=null;g.setPath(a,b,c)};m.get=function(){return r};m.prefix=function(a){g.prefix=a};m.link=function(a){a.dom.setAttribute("href",g.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||
|
||||
(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(g.prefix)&&(a=a.slice(g.prefix.length)),m.set(a,void 0,void 0))}};return m}(window,F);A.withAttr=function(a,c,g){return function(d){return c.call(g||this,a in d.currentTarget?d.currentTarget[a]:d.currentTarget.getAttribute(a))}};var S=M(window);A.render=S.render;A.redraw=F.redraw;A.request=I.request;A.jsonp=I.jsonp;A.parseQueryString=J;A.buildQueryString=D;A.version="1.0.0-rc.6";A.vnode=w;"undefined"!==typeof module?module.exports=
|
||||
A:window.m=A};
|
||||
|
|
@ -15,6 +15,7 @@ function traverseDirectory(pathname, callback) {
|
|||
if (err) reject(err)
|
||||
var promises = []
|
||||
for (var i = 0; i < pathnames.length; i++) {
|
||||
if (pathnames[i] === "node_modules") continue
|
||||
pathnames[i] = path.join(pathname, pathnames[i])
|
||||
promises.push(traverseDirectory(pathnames[i], callback))
|
||||
}
|
||||
|
|
@ -31,7 +32,6 @@ function traverseDirectory(pathname, callback) {
|
|||
}
|
||||
|
||||
traverseDirectory(".", function(pathname, stat, children) {
|
||||
if (pathname.indexOf("node_modules") > -1) return
|
||||
if (pathname.match(/(?:^|\/)tests\/.*\.js$/)) {
|
||||
require(path.normalize(process.cwd()) + "/" + pathname)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,9 +95,12 @@ PromisePolyfill.race = function(list) {
|
|||
})
|
||||
}
|
||||
|
||||
if (typeof Promise === "undefined") {
|
||||
if (typeof window !== "undefined") window.Promise = PromisePolyfill
|
||||
else if (typeof global !== "undefined") global.Promise = PromisePolyfill
|
||||
if (typeof window !== "undefined") {
|
||||
if (typeof window.Promise === "undefined") window.Promise = PromisePolyfill
|
||||
module.exports = window.Promise
|
||||
} else if (typeof global !== "undefined") {
|
||||
if (typeof global.Promise === "undefined") global.Promise = PromisePolyfill
|
||||
module.exports = global.Promise
|
||||
} else {
|
||||
module.exports = PromisePolyfill
|
||||
}
|
||||
|
||||
module.exports = typeof Promise !== "undefined" ? Promise : PromisePolyfill
|
||||
Loading…
Add table
Add a link
Reference in a new issue