Comparing version
"use strict" | ||
var fs = require("fs"); | ||
var zlib = require("zlib") | ||
@@ -8,3 +9,3 @@ var bundle = require("./bundle") | ||
var aliases = {o: "output", m: "minify", w: "watch", a: "aggressive", s: "save"} | ||
var aliases = {o: "output", m: "minify", w: "watch", s: "save"} | ||
var params = {} | ||
@@ -28,24 +29,29 @@ var args = process.argv.slice(2), command = null | ||
function format(n) { | ||
return n.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") | ||
} | ||
bundle(params.input, params.output, {watch: params.watch}) | ||
if (params.minify) { | ||
minify(params.output, params.output, {watch: params.watch, advanced: params.aggressive}, function(stats) { | ||
function format(n) { | ||
return n.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,") | ||
} | ||
// mFiles = { original: String(mithril.js), compressed: String(mithril.min.js) } | ||
var mFiles = minify(params.output, {watch: params.watch}) | ||
var originalSize = mFiles.original.length | ||
var compressedSize = mFiles.compressed.length | ||
var originalGzipSize = zlib.gzipSync(mFiles.original).byteLength | ||
var compressedGzipSize = zlib.gzipSync(mFiles.compressed).byteLength | ||
console.log("Original size: " + format(stats.originalGzipSize) + " bytes gzipped (" + format(stats.originalSize) + " bytes uncompressed)") | ||
console.log("Compiled size: " + format(stats.compressedGzipSize) + " bytes gzipped (" + format(stats.compressedSize) + " bytes uncompressed)") | ||
console.log("Original size: " + format(originalGzipSize) + " bytes gzipped (" + format(originalSize) + " bytes uncompressed)") | ||
console.log("Compiled size: " + format(compressedGzipSize) + " bytes gzipped (" + format(compressedSize) + " bytes uncompressed)") | ||
if (params.save) { | ||
var readme = fs.readFileSync("./README.md", "utf8") | ||
var kb = stats.compressedGzipSize / 1000 | ||
if (params.save) { | ||
var readme = fs.readFileSync("./README.md", "utf8") | ||
var kb = compressedGzipSize / 1000 | ||
fs.writeFileSync("./README.md", | ||
readme.replace( | ||
/(<!-- size -->)(.+?)(<!-- \/size -->)/, | ||
"$1" + (kb % 1 ? kb.toFixed(2) : kb) + " KB$3" | ||
) | ||
fs.writeFileSync("./README.md", | ||
readme.replace( | ||
/(<!-- size -->)(.+?)(<!-- \/size -->)/, | ||
"$1" + (kb % 1 ? kb.toFixed(2) : kb) + " KB$3" | ||
) | ||
} | ||
}) | ||
} | ||
) | ||
} | ||
} |
"use strict" | ||
var http = require("https") | ||
var querystring = require("querystring") | ||
var fs = require("fs") | ||
var UglifyES = require("uglify-es") | ||
module.exports = function(input, output, options, done) { | ||
function minify(input, output) { | ||
var code = fs.readFileSync(input, "utf8") | ||
module.exports = function(filePath, options) { | ||
function minify(filePath) { | ||
var original = fs.readFileSync(filePath, "utf8"), | ||
uglified = UglifyES.minify(original), | ||
compressed = uglified.code | ||
if (uglified.error) throw new Error(uglified.error) | ||
var data = { | ||
output_format: "json", | ||
output_info: ["compiled_code", "warnings", "errors", "statistics"], | ||
compilation_level: options.advanced ? "ADVANCED_OPTIMIZATIONS" : "SIMPLE_OPTIMIZATIONS", | ||
warning_level: "default", | ||
output_file_name: "default.js", | ||
js_code: code, | ||
} | ||
fs.writeFileSync(filePath, compressed, "utf8") | ||
return {original: original, compressed: compressed} | ||
} | ||
var body = querystring.stringify(data) | ||
var response = "" | ||
var req = http.request({ | ||
method: "POST", | ||
hostname: "closure-compiler.appspot.com", | ||
path: "/compile", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8", | ||
"Content-Length": body.length | ||
} | ||
}, function(res) { | ||
res.on("data", function(chunk) { | ||
response += chunk.toString() | ||
}) | ||
res.on("end", function() { | ||
try { | ||
var results = JSON.parse(response) | ||
} catch(e) { | ||
console.error(response); | ||
throw e; | ||
} | ||
if (results.errors) { | ||
for (var i = 0; i < results.errors.length; i++) console.log(results.errors[i]) | ||
} | ||
else { | ||
fs.writeFileSync(output, results.compiledCode, "utf8") | ||
console.log("done") | ||
if(typeof done === "function") done(results.statistics) | ||
} | ||
}) | ||
}) | ||
req.write(body) | ||
req.end() | ||
function run() { | ||
console.log("minifying...") | ||
return minify(filePath) | ||
} | ||
function run() { | ||
minify(input, output) | ||
} | ||
run() | ||
if (options && options.watch) fs.watchFile(input, run) | ||
if (options && options.watch) fs.watchFile(filePath, run) | ||
return run() | ||
} |
@@ -146,2 +146,22 @@ # API | ||
#### m.prop(initial) - [docs](prop.md) | ||
```javascript | ||
var Component = { | ||
oninit: function(vnode) { | ||
vnode.state.current = m.prop("") | ||
}, | ||
view: function(vnode) { | ||
return m("input", { | ||
oninput: function(ev) { vnode.state.current.set(ev.target.value) }, | ||
value: vnode.state.current.get(), | ||
}) | ||
} | ||
} | ||
m.mount(document.body, Component) | ||
``` | ||
--- | ||
#### m.trust(htmlString) - [docs](trust.md) | ||
@@ -148,0 +168,0 @@ |
@@ -46,2 +46,3 @@ # Change log | ||
- render/core: revamp the core diff engine, and introduce a longest-increasing-subsequence-based logic to minimize DOM operations when re-ordering keyed nodes. | ||
- API: Introduction of `m.prop()` ([#2268](https://github.com/MithrilJS/mithril.js/pull/2268)) | ||
@@ -62,4 +63,5 @@ #### Bug fixes | ||
- render/hooks: fixed an ommission that caused `oninit` to be called unnecessarily in some cases [#1992](https://github.com/MithrilJS/mithril.js/issues/1992) | ||
- docs: tweaks: ([#2104](https://github.com/MithrilJS/mithril.js/pull/2104) [@mikeyb](https://github.com/mikeyb), [#2205](https://github.com/MithrilJS/mithril.js/pull/2205), [@cavemansspa](https://github.com/cavemansspa)) | ||
- docs: tweaks: ([#2104](https://github.com/MithrilJS/mithril.js/pull/2104) [@mikeyb](https://github.com/mikeyb), [#2205](https://github.com/MithrilJS/mithril.js/pull/2205), [@cavemansspa](https://github.com/cavemansspa), [#2265](https://github.com/MithrilJS/mithril.js/pull/2265), [@isiahmeadows](https://github.com/isiahmeadows)) | ||
- render/core: avoid touching `Object.prototype.__proto__` setter with `key: "__proto__"` in certain situations ([#2251](https://github.com/MithrilJS/mithril.js/pull/2251)) | ||
- render/core: Vnodes stored in the dom node supplied to `m.render()` are now normalized [#2266](https://github.com/MithrilJS/mithril.js/pull/2266) | ||
@@ -78,25 +80,2 @@ --- | ||
- core: render() function can no longer prevent from changing `document.activeElement` in lifecycle hooks ([#1988](https://github.com/MithrilJS/mithril.js/pull/1988), [@purplecode](https://github.com/purplecode)) | ||
- core: don't call `onremove` on the children of components that return null from the view [#1921](https://github.com/MithrilJS/mithril.js/issues/1921) [@octavore](https://github.com/octavore) ([#1922](https://github.com/MithrilJS/mithril.js/pull/1922)) | ||
- hypertext: correct handling of shared attributes object passed to `m()`. Will copy attributes when it's necessary [#1941](https://github.com/MithrilJS/mithril.js/issues/1941) [@s-ilya](https://github.com/s-ilya) ([#1942](https://github.com/MithrilJS/mithril.js/pull/1942)) | ||
--- | ||
### v1.1.5 | ||
- API: If a user sets the Content-Type header within a request's options, that value will be the entire header value rather than being appended to the default value ([#1924](https://github.com/MithrilJS/mithril.js/pull/1924)) | ||
--- | ||
### v1.1.4 | ||
#### Bug fixes: | ||
- Fix IE bug where active element is null causing render function to throw error ([#1943](https://github.com/MithrilJS/mithril.js/pull/1943), [@JacksonJN](https://github.com/JacksonJN)) | ||
--- | ||
### v1.1.6 | ||
#### Bug fixes | ||
@@ -103,0 +82,0 @@ |
@@ -366,32 +366,2 @@ # Components | ||
#### Avoid restrictive interfaces | ||
Try to keep component interfaces generic - using `attrs` and `children` directly - unless the component requires special logic to operate on input. | ||
In the example below, the `button` configuration is severely limited: it does not support any events other than `onclick`, it's not styleable and it only accepts text as children (but not elements, fragments or trusted HTML). | ||
```javascript | ||
// AVOID | ||
var RestrictiveComponent = { | ||
view: function(vnode) { | ||
return m("button", {onclick: vnode.attrs.onclick}, [ | ||
"Click to " + vnode.attrs.text | ||
]) | ||
} | ||
} | ||
``` | ||
If the required attributes are equivalent to generic DOM attributes, it's preferable to allow passing through parameters to a component's root node. | ||
```javascript | ||
// PREFER | ||
var FlexibleComponent = { | ||
view: function(vnode) { | ||
return m("button", vnode.attrs, [ | ||
"Click to ", vnode.children | ||
]) | ||
} | ||
} | ||
``` | ||
#### Don't manipulate `children` | ||
@@ -398,0 +368,0 @@ |
@@ -281,2 +281,25 @@ # m(selector, attributes, children) | ||
Mithril accepts functions and [EventListener](https://developer.mozilla.org/en-US/docs/Web/API/EventListener) objects. So this will also work: | ||
```javascript | ||
var clickListener = { | ||
handleEvent: function(e) { | ||
console.log(e) | ||
} | ||
} | ||
m("div", {onclick: clickListener}) | ||
``` | ||
By default, when an event attached with hyperscript fires, this will trigger Mithril's auto-redraw after your event callback returns (assuming you are using `m.mount` or `m.route` instead of `m.render` directly). You can disable auto-redraw specifically for a single event by setting `e.redraw = false` on it: | ||
```javascript | ||
m("div", { | ||
onclick: function(e) { | ||
// Prevent auto-redraw | ||
e.redraw = false | ||
} | ||
}) | ||
``` | ||
--- | ||
@@ -283,0 +306,0 @@ |
@@ -235,3 +235,3 @@ # Installation | ||
"scripts": { | ||
"build": "bundle index.js --output app.js --watch" | ||
"build": "bundle src/index.js --output bin/app.js --watch" | ||
} | ||
@@ -238,0 +238,0 @@ } |
@@ -11,2 +11,3 @@ - Core | ||
- [m.withAttr](withAttr.md) | ||
- [m.prop](prop.md) | ||
- [m.trust](trust.md) | ||
@@ -13,0 +14,0 @@ - [m.fragment](fragment.md) |
@@ -12,2 +12,3 @@ "use strict" | ||
m.withAttr = require("./util/withAttr") | ||
m.prop = require("./util/prop") | ||
m.render = require("./render").render | ||
@@ -14,0 +15,0 @@ m.redraw = redrawService.redraw |
@@ -11,3 +11,3 @@ ;(function() { | ||
} | ||
Vnode.normalizeChildren = function normalizeChildren(input) { | ||
Vnode.normalizeChildren = function(input) { | ||
var children = [] | ||
@@ -1244,4 +1244,4 @@ for (var i = 0; i < input.length; i++) { | ||
if (dom.vnodes == null) dom.textContent = "" | ||
if (!Array.isArray(vnodes)) vnodes = [vnodes] | ||
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace) | ||
vnodes = Vnode.normalizeChildren(Array.isArray(vnodes) ? vnodes : [vnodes]) | ||
updateNodes(dom, dom.vnodes, vnodes, hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace) | ||
dom.vnodes = vnodes | ||
@@ -1517,4 +1517,11 @@ // document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement | ||
} | ||
var _29 = coreRenderer(window) | ||
m.render = _29.render | ||
m.prop = function (store) { | ||
return { | ||
get: function() { return store }, | ||
toJSON: function() { return store }, | ||
set: function(value0) { return store = value0 } | ||
} | ||
} | ||
var _30 = coreRenderer(window) | ||
m.render = _30.render | ||
m.redraw = redrawService.redraw | ||
@@ -1525,3 +1532,3 @@ m.request = requestService.request | ||
m.buildQueryString = buildQueryString | ||
m.version = "2.0.0-rc.0" | ||
m.version = "2.0.0-rc.1" | ||
m.vnode = Vnode | ||
@@ -1528,0 +1535,0 @@ m.PromisePolyfill = PromisePolyfill |
@@ -1,48 +0,1 @@ | ||
(function(){function x(a,d,e,g,q,k){return{tag:a,key:d,attrs:e,children:g,text:q,dom:k,domSize:void 0,state:void 0,events:void 0,instance:void 0}}function Q(a){for(var d in a)if(G.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 g=arguments[e];Array.isArray(g)||(g=[g])}else for(g=[];e<arguments.length;)g.push(arguments[e++]);if("string"===typeof a){if(!(e=R[a])){for(var q="div",k=[],h={};e=W.exec(a);){var m=e[1],n=e[2];""===m&&""!==n?q=n:"#"===m?h.id=n:"."===m?k.push(n):"["===e[3][0]&&((m=e[6])&&(m=m.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===e[4]?k.push(m):h[e[4]]=""===m?m:m||!0)}0<k.length&&(h.className=k.join(" "));e=R[a]={tag:q,attrs:h}}g=x.normalizeChildren(g);q=!1;var l,C;k=G.call(d,"class")? | ||
"class":"className";h=d[k];if(!Q(e.attrs)&&!Q(d)){m={};for(var c in d)G.call(d,c)&&(m[c]=d[c]);d=m}for(c in e.attrs)G.call(e.attrs,c)&&"className"!==c&&!G.call(d,c)&&(d[c]=e.attrs[c]);if(null!=h||null!=e.attrs.className)d.className=null!=h?null!=e.attrs.className?e.attrs.className+" "+h:h:null!=e.attrs.className?e.attrs.className:null;"class"===k&&(d["class"]=null);for(c in d)if(G.call(d,c)&&"key"!==c){q=!0;break}Array.isArray(g)&&1===g.length&&null!=g[0]&&"#"===g[0].tag?C=g[0].children:l=g;return x(e.tag, | ||
d.key,q?d:null,l,C)}return x(a,d.key,d,g)}function X(a){var d=0,e=null,g="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var q=Date.now()-d;null===e&&(e=g(function(){e=null;a();d=Date.now()},16-q))}}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=[],e=0;e<a.length;e++)d[e]=x.normalize(a[e]); | ||
return d};var W=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,R={},G={}.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 p=function(a){function d(a,c){return function K(d){var F;try{if(!c||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(F=d.then))l(function(){c||0!==a.length||console.error("Possible unhandled promise rejection:", | ||
d);for(var e=0;e<a.length;e++)a[e](d);q.length=0;k.length=0;n.state=c;n.retry=function(){K(d)}});else{if(d===g)throw new TypeError("Promise can't be resolved w/ itself");e(F.bind(d))}}catch(Y){m(Y)}}}function e(a){function c(c){return function(a){0<d++||c(a)}}var d=0,e=c(m);try{a(c(h),e)}catch(K){e(K)}}if(!(this instanceof p))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var g=this,q=[],k=[],h=d(q,!0),m=d(k,!1),n=g._instance= | ||
{resolvers:q,rejectors:k},l="function"===typeof setImmediate?setImmediate:setTimeout;e(a)};p.prototype.then=function(a,d){function e(a,d,e,h){d.push(function(c){if("function"!==typeof a)e(c);else try{q(a(c))}catch(y){k&&k(y)}});"function"===typeof g.retry&&h===g.state&&g.retry()}var g=this._instance,q,k,h=new p(function(a,d){q=a;k=d});e(a,g.resolvers,q,!0);e(d,g.rejectors,k,!1);return h};p.prototype["catch"]=function(a){return this.then(null,a)};p.prototype["finally"]=function(a){return this.then(function(d){return p.resolve(a()).then(function(){return d})}, | ||
function(d){return p.resolve(a()).then(function(){return p.reject(d)})})};p.resolve=function(a){return a instanceof p?a:new p(function(d){d(a)})};p.reject=function(a){return new p(function(d,e){e(a)})};p.all=function(a){return new p(function(d,e){var g=a.length,q=0,k=[];if(0===a.length)d([]);else for(var h=0;h<a.length;h++)(function(m){function n(a){q++;k[m]=a;q===g&&d(k)}null==a[m]||"object"!==typeof a[m]&&"function"!==typeof a[m]||"function"!==typeof a[m].then?n(a[m]):a[m].then(n,e)})(h)})};p.race= | ||
function(a){return new p(function(d,e){for(var g=0;g<a.length;g++)a[g].then(d,e)})};"undefined"!==typeof window?("undefined"===typeof window.Promise?window.Promise=p:window.Promise.prototype["finally"]||(window.Promise.prototype["finally"]=p.prototype["finally"]),p=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise?global.Promise=p:global.Promise.prototype["finally"]||(global.Promise.prototype["finally"]=p.prototype["finally"]),p=global.Promise);var H=function(a){function d(a, | ||
g){if(Array.isArray(g))for(var h=0;h<g.length;h++)d(a+"["+h+"]",g[h]);else if("[object Object]"===Object.prototype.toString.call(g))for(h in g)d(a+"["+h+"]",g[h]);else e.push(encodeURIComponent(a)+(null!=g&&""!==g?"="+encodeURIComponent(g):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var e=[],g;for(g in a)d(g,a[g]);return e.join("&")},Z=/^file:\/\//i,O=function(a,d){function e(){function c(){0===--a&&"function"===typeof C&&C()}var a=0;return function D(d){var e=d.then;d.then= | ||
function(){a++;var g=e.apply(d,arguments);g.then(c,function(d){c();if(0===a)throw d;});return D(g)};return d}}function g(c,a){if("string"===typeof c){var d=c;c=a||{};null==c.url&&(c.url=d)}return c}function q(c,a){if(null==a)return c;for(var d=c.match(/:[^\/]+/gi)||[],e=0;e<d.length;e++){var g=d[e].slice(1);null!=a[g]&&(c=c.replace(d[e],a[g]))}return c}function k(c,a){var d=H(a);if(""!==d){var e=0>c.indexOf("?")?"?":"&";c+=e+d}return c}function h(c){try{return""!==c?JSON.parse(c):null}catch(y){throw Error("Invalid JSON: "+ | ||
c);}}function m(c){return c.responseText}function n(c,a){if("function"===typeof c)if(Array.isArray(a))for(var d=0;d<a.length;d++)a[d]=new c(a[d]);else return new c(a);return a}var l=0,C;return{request:function(c,l){var F=e();c=g(c,l);var y=new d(function(d,e){null==c.method&&(c.method="GET");c.method=c.method.toUpperCase();var g="GET"===c.method||"TRACE"===c.method?!1:"boolean"===typeof c.useBody?c.useBody:!0;"function"!==typeof c.serialize&&(c.serialize="undefined"!==typeof FormData&&c.data instanceof | ||
FormData?function(c){return c}:JSON.stringify);"function"!==typeof c.deserialize&&(c.deserialize=h);"function"!==typeof c.extract&&(c.extract=m);c.url=q(c.url,c.data);g?c.data=c.serialize(c.data):c.url=k(c.url,c.data);var l=new a.XMLHttpRequest,F=!1,y=l.abort;l.abort=function(){F=!0;y.call(l)};l.open(c.method,c.url,"boolean"===typeof c.async?c.async:!0,"string"===typeof c.user?c.user:void 0,"string"===typeof c.password?c.password:void 0);c.serialize!==JSON.stringify||!g||c.headers&&c.headers.hasOwnProperty("Content-Type")|| | ||
l.setRequestHeader("Content-Type","application/json; charset=utf-8");c.deserialize!==h||c.headers&&c.headers.hasOwnProperty("Accept")||l.setRequestHeader("Accept","application/json, text/*");c.withCredentials&&(l.withCredentials=c.withCredentials);c.timeout&&(l.timeout=c.timeout);c.responseType&&(l.responseType=c.responseType);for(var C in c.headers)({}).hasOwnProperty.call(c.headers,C)&&l.setRequestHeader(C,c.headers[C]);"function"===typeof c.config&&(l=c.config(l,c)||l);l.onreadystatechange=function(){if(!F&& | ||
4===l.readyState)try{var a=c.extract!==m?c.extract(l,c):c.deserialize(c.extract(l,c));if(c.extract!==m||200<=l.status&&300>l.status||304===l.status||Z.test(c.url))d(n(c.type,a));else{var g=Error(l.responseText);g.code=l.status;g.response=a;e(g)}}catch(aa){e(aa)}};g&&null!=c.data?l.send(c.data):l.send()});return!0===c.background?y:F(y)},jsonp:function(c,m){var h=e();c=g(c,m);var y=new d(function(d,e){var g=c.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+l++,m=a.document.createElement("script"); | ||
a[g]=function(e){m.parentNode.removeChild(m);d(n(c.type,e));delete a[g]};m.onerror=function(){m.parentNode.removeChild(m);e(Error("JSONP request failed"));delete a[g]};null==c.data&&(c.data={});c.url=q(c.url,c.data);c.data[c.callbackKey||"callback"]=g;m.src=k(c.url,c.data);a.document.documentElement.appendChild(m)});return!0===c.background?y:h(y)},setCompletionCallback:function(c){C=c}}}(window,p),V=function(a){function d(t,b){if(t.state!==b)throw Error("`vnode.state` must not be modified");}function e(t){var b= | ||
t.state;try{return this.apply(b,arguments)}finally{d(t,b)}}function g(t,b,f,c,a,d,e){for(;f<c;f++){var g=b[f];null!=g&&q(t,g,a,e,d)}}function q(t,b,f,a,d){var n=b.tag;if("string"===typeof n)switch(b.state={},null!=b.attrs&&N(b.attrs,b,f),n){case "#":b.dom=E.createTextNode(b.children);C(t,b.dom,d);break;case "<":k(t,b,a,d);break;case "[":n=E.createDocumentFragment();if(null!=b.children){var l=b.children;g(n,l,0,l.length,f,null,a)}b.dom=n.firstChild;b.domSize=n.childNodes.length;C(t,n,d);break;default:var m= | ||
b.tag,u=(n=b.attrs)&&n.is;m=(a=b.attrs&&b.attrs.xmlns||G[b.tag]||a)?u?E.createElementNS(a,m,{is:u}):E.createElementNS(a,m):u?E.createElement(m,{is:u}):E.createElement(m);b.dom=m;if(null!=n)for(l in u=a,n)D(b,l,null,n[l],u);C(t,m,d);if(null!=n&&null!=n.contenteditable)c(b);else if(null!=b.text&&(""!==b.text?m.textContent=b.text:b.children=[x("#",void 0,void 0,b.text,void 0,void 0)]),null!=b.children&&(t=b.children,g(m,t,0,t.length,f,null,a),"select"===b.tag&&null!=n)){if("value"in n)if(null===n.value)-1!== | ||
b.dom.selectedIndex&&(b.dom.value=null);else if(f=""+n.value,b.dom.value!==f||-1===b.dom.selectedIndex)b.dom.value=f;"selectedIndex"in n&&D(b,"selectedIndex",null,n.selectedIndex,void 0)}}else{a:{if("function"===typeof b.tag.view){b.state=Object.create(b.tag);n=b.state.view;if(null!=n.$$reentrantLock$$)break a;n.$$reentrantLock$$=!0}else{b.state=void 0;n=b.tag;if(null!=n.$$reentrantLock$$)break a;n.$$reentrantLock$$=!0;b.state=null!=b.tag.prototype&&"function"===typeof b.tag.prototype.view?new b.tag(b): | ||
b.tag(b)}null!=b.attrs&&N(b.attrs,b,f);N(b.state,b,f);b.instance=x.normalize(e.call(b.state.view,b));if(b.instance===b)throw Error("A view cannot return the vnode it received as argument");n.$$reentrantLock$$=null}null!=b.instance?(q(t,b.instance,f,a,d),b.dom=b.instance.dom,b.domSize=null!=b.dom?b.instance.domSize:0):b.domSize=0}}function k(t,b,f,c){var a=b.children.match(/^\s*?<(\w+)/im)||[];a=E.createElement(I[a[1]]||"div");"http://www.w3.org/2000/svg"===f?(a.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+ | ||
b.children+"</svg>",a=a.firstChild):a.innerHTML=b.children;b.dom=a.firstChild;b.domSize=a.childNodes.length;for(b=E.createDocumentFragment();f=a.firstChild;)b.appendChild(f);C(t,b,c)}function h(t,b,f,c,a,d){if(b!==f&&(null!=b||null!=f))if(null==b||0===b.length)g(t,f,0,f.length,c,a,d);else if(null==f||0===f.length)y(b,0,b.length);else{for(var e=0,u=0,h=null,k=null;u<b.length;u++)if(null!=b[u]){h=null!=b[u].key;break}for(;e<f.length;e++)if(null!=f[e]){k=null!=f[e].key;break}if(null!==k||null!=h)if(h!== | ||
k)y(b,u,b.length),g(t,f,e,f.length,c,a,d);else if(k){k=b.length-1;h=f.length-1;for(var p,r,v,A,z,B;k>=u&&h>=e;)if(A=b[k],z=f[h],null==A)k--;else if(null==z)h--;else if(A.key===z.key)A!==z&&m(t,A,z,c,a,d),null!=z.dom&&(a=z.dom),k--,h--;else break;for(;k>=u&&h>=e;)if(r=b[u],v=f[e],null==r)u++;else if(null==v)e++;else if(r.key===v.key)u++,e++,r!==v&&m(t,r,v,c,l(b,u,a),d);else break;for(;k>=u&&h>=e;){if(null==r)u++;else if(null==v)e++;else if(null==A)k--;else if(null==z)h--;else if(e===h)break;else{if(r.key!== | ||
z.key||A.key!==v.key)break;B=l(b,u,a);C(t,n(A),B);A!==v&&m(t,A,v,c,B,d);++e<=--h&&C(t,n(r),a);r!==z&&m(t,r,z,c,a,d);null!=z.dom&&(a=z.dom);u++;k--}A=b[k];z=f[h];r=b[u];v=f[e]}for(;k>=u&&h>=e;){if(null==A)k--;else if(null==z)h--;else if(A.key===z.key)A!==z&&m(t,A,z,c,a,d),null!=z.dom&&(a=z.dom),k--,h--;else break;A=b[k];z=f[h]}if(e>h)y(b,u,k+1);else if(u>k)g(t,f,e,h+1,c,a,d);else{v=a;A=h-e+1;r=Array(A);var x=2147483647,w=0;for(B=0;B<A;B++)r[B]=-1;for(B=h;B>=e;B--){if(null==p){p=b;A=u;z=k+1;for(var D= | ||
Object.create(null);A<z;A++){var J=p[A];null!=J&&(J=J.key,null!=J&&(D[J]=A))}p=D}z=f[B];null!=z&&(D=p[z.key],null!=D&&(x=D<x?D:-1,r[B-e]=D,A=b[D],b[D]=null,A!==z&&m(t,A,z,c,a,d),null!=z.dom&&(a=z.dom),w++))}a=v;w!==k-u+1&&y(b,u,k+1);if(0===w)g(t,f,e,h+1,c,a,d);else if(-1===x){u=r.slice();b=[];b.push(0);k=0;for(B=r.length;k<B;++k)if(-1!==r[k])if(v=b[b.length-1],r[v]<r[k])u[k]=v,b.push(k);else{v=0;for(x=b.length-1;v<x;)w=(v+x)/2|0,r[b[w]]<r[k]?v=w+1:x=w;r[k]<r[b[v]]&&(0<v&&(u[k]=b[v-1]),b[v]=k)}v=b.length; | ||
for(x=b[v-1];0<v--;)b[v]=x,x=u[x];u=b.length-1;for(B=h;B>=e;B--)v=f[B],-1===r[B-e]?q(t,v,c,d,a):b[u]===B-e?u--:C(t,n(v),a),null!=v.dom&&(a=f[B].dom)}else for(B=h;B>=e;B--)v=f[B],-1===r[B-e]&&q(t,v,c,d,a),null!=v.dom&&(a=f[B].dom)}}else{h=b.length<f.length?b.length:f.length;for(e=e<u?e:u;e<h;e++)r=b[e],v=f[e],r===v||null==r&&null==v||(null==r?q(t,v,c,d,l(b,e+1,a)):null==v?F(r):m(t,r,v,c,l(b,e+1,a),d));b.length>h&&y(b,e,b.length);f.length>h&&g(t,f,e,f.length,c,a,d)}}}function m(a,b,f,d,g,l){var t=b.tag; | ||
if(t===f.tag){f.state=b.state;f.events=b.events;var u;var y;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(u=e.call(f.attrs.onbeforeupdate,f,b));"string"!==typeof f.tag&&"function"===typeof f.state.onbeforeupdate&&(y=e.call(f.state.onbeforeupdate,f,b));void 0===u&&void 0===y||u||y?u=!1:(f.dom=b.dom,f.domSize=b.domSize,f.instance=b.instance,u=!0);if(!u)if("string"===typeof t)switch(null!=f.attrs&&L(f.attrs,f,d),t){case "#":b.children.toString()!==f.children.toString()&&(b.dom.nodeValue= | ||
f.children);f.dom=b.dom;break;case "<":b.children!==f.children?(n(b),k(a,f,l,g)):(f.dom=b.dom,f.domSize=b.domSize);break;case "[":h(a,b.children,f.children,d,g,l);b=0;d=f.children;f.dom=null;if(null!=d){for(var p=0;p<d.length;p++)a=d[p],null!=a&&null!=a.dom&&(null==f.dom&&(f.dom=a.dom),b+=a.domSize||1);1!==b&&(f.domSize=b)}break;default:a=f.dom=b.dom;l=f.attrs&&f.attrs.xmlns||G[f.tag]||l;"textarea"===f.tag&&(null==f.attrs&&(f.attrs={}),null!=f.text&&(f.attrs.value=f.text,f.text=void 0));g=b.attrs; | ||
t=f.attrs;u=l;if(null!=t)for(p in t)D(f,p,g&&g[p],t[p],u);var C;if(null!=g)for(p in g)if(null!=(C=g[p])&&(null==t||null==t[p])){y=f;var r=p,v=u;"key"===r||"is"===r||null==C||w(r)||("o"!==r[0]||"n"!==r[1]||w(r)?"style"===r?T(y.dom,C,null):!S(y,r,v)||"className"===r||"option"===y.tag&&"value"===r||"input"===y.tag&&"type"===r?(v=r.indexOf(":"),-1!==v&&(r=r.slice(v+1)),!1!==C&&y.dom.removeAttribute("className"===r?"class":r)):y.dom[r]=null:U(y,r,void 0))}null!=f.attrs&&null!=f.attrs.contenteditable?c(f): | ||
null!=b.text&&null!=f.text&&""!==f.text?b.text.toString()!==f.text.toString()&&(b.dom.firstChild.nodeValue=f.text):(null!=b.text&&(b.children=[x("#",void 0,void 0,b.text,void 0,b.dom.firstChild)]),null!=f.text&&(f.children=[x("#",void 0,void 0,f.text,void 0,void 0)]),h(a,b.children,f.children,d,null,l))}else{f.instance=x.normalize(e.call(f.state.view,f));if(f.instance===f)throw Error("A view cannot return the vnode it received as argument");null!=f.attrs&&L(f.attrs,f,d);L(f.state,f,d);null!=f.instance? | ||
(null==b.instance?q(a,f.instance,d,l,g):m(a,b.instance,f.instance,d,g,l),f.dom=f.instance.dom,f.domSize=f.instance.domSize):null!=b.instance?(F(b.instance),f.dom=void 0,f.domSize=0):(f.dom=b.dom,f.domSize=b.domSize)}}else F(b),q(a,f,d,l,g)}function n(a){var b=a.domSize;if(null!=b||null==a.dom){var c=E.createDocumentFragment();if(0<b){for(a=a.dom;--b;)c.appendChild(a.nextSibling);c.insertBefore(a,c.firstChild)}return c}return a.dom}function l(a,b,c){for(;b<a.length;b++)if(null!=a[b]&&null!=a[b].dom)return a[b].dom; | ||
return c}function C(a,b,c){null!=c?a.insertBefore(b,c):a.appendChild(b)}function c(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 y(a,b,c){for(;b<c;b++){var f=a[b];null!=f&&F(f)}}function F(a){function b(){if(++t===c&&(d(a,g),p(a),a.dom)){for(var b=a.dom.parentNode,f=a.domSize||1;--f;)b.removeChild(a.dom.nextSibling); | ||
b.removeChild(a.dom)}}var c=1,t=0,g=a.state;if(a.attrs&&"function"===typeof a.attrs.onbeforeremove){var n=e.call(a.attrs.onbeforeremove,a);null!=n&&"function"===typeof n.then&&(c++,n.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a.state.onbeforeremove&&(n=e.call(a.state.onbeforeremove,a),null!=n&&"function"===typeof n.then&&(c++,n.then(b,b)));b()}function p(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&&p(a.instance);else if(a=a.children,Array.isArray(a))for(var b=0;b<a.length;b++){var c=a[b];null!=c&&p(c)}}function D(a,b,c,d,e){if("key"!==b&&"is"!==b&&null!=d&&!w(b)&&(c!==d||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===E.activeElement||"option"===a.tag&&a.dom.parentNode===E.activeElement||"object"===typeof d)){if("o"===b[0]&&"n"===b[1])return U(a,b,d);"xlink:"===b.slice(0,6)?a.dom.setAttributeNS("http://www.w3.org/1999/xlink", | ||
b.slice(6),d):"style"===b?T(a.dom,c,d):S(a,b,e)?"value"===b&&(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===""+d&&a.dom===E.activeElement||"select"===a.tag&&null!==c&&a.dom.value===""+d||"option"===a.tag&&null!==c&&a.dom.value===""+d)||("input"===a.tag&&"type"===b?a.dom.setAttribute(b,d):a.dom[b]=d):"boolean"===typeof d?d?a.dom.setAttribute(b,""):a.dom.removeAttribute(b):a.dom.setAttribute("className"===b?"class":b,d)}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"=== | ||
a||"onbeforeremove"===a||"onbeforeupdate"===a}function S(a,b,c){return void 0===c&&(-1<a.tag.indexOf("-")||null!=a.attrs&&a.attrs.is||"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b)&&b in a.dom}function T(a,b,c){if(null!=b&&null!=c&&"object"===typeof b&&"object"===typeof c&&c!==b){for(var d in c)c[d]!==b[d]&&(a.style[d]=c[d]);for(d in b)d in c||(a.style[d]="")}else if(b===c&&(a.style.cssText="",b=null),null==c)a.style.cssText="";else if("string"===typeof c)a.style.cssText=c;else for(d in"string"=== | ||
typeof b&&(a.style.cssText=""),c)a.style[d]=c[d]}function M(){}function U(a,b,c){null!=a.events?a.events[b]!==c&&(null==c||"function"!==typeof c&&"object"!==typeof c?(null!=a.events[b]&&a.dom.removeEventListener(b.slice(2),a.events,!1),a.events[b]=void 0):(null==a.events[b]&&a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)):null==c||"function"!==typeof c&&"object"!==typeof c||(a.events=new M,a.dom.addEventListener(b.slice(2),a.events,!1),a.events[b]=c)}function N(a,b,c){"function"=== | ||
typeof a.oninit&&e.call(a.oninit,b);"function"===typeof a.oncreate&&c.push(e.bind(a.oncreate,b))}function L(a,b,c){"function"===typeof a.onupdate&&c.push(e.bind(a.onupdate,b))}var E=a.document,G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},H,I={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};M.prototype=Object.create(null);M.prototype.handleEvent=function(a){var b=this["on"+a.type],c;"function"=== | ||
typeof b?c=b.call(a.target,a):"function"===typeof b.handleEvent&&b.handleEvent(a);"function"===typeof H&&H.call(a.target,a);!1===c&&(a.preventDefault(),a.stopPropagation())};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=E.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);h(a,a.vnodes,x.normalizeChildren(b),c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes= | ||
b;null!=d&&E.activeElement!==d&&"function"===typeof d.focus&&d.focus();for(d=0;d<c.length;d++)c[d]()},setEventCallback:function(a){return H=a}}},I=function(a,d){function e(a){a=k.indexOf(a);-1<a&&k.splice(a,2)}function g(){if(h)throw Error("Nested m.redraw.sync() call");h=!0;for(var a=1;a<k.length;a+=2)try{k[a]()}catch(l){"undefined"!==typeof console&&console.error(l)}h=!1}var q=V(a);q.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:m()});var k=[],h=!1,m=(d||X)(g);m.sync=g;return{subscribe:function(a, | ||
d){e(a);k.push(a,d)},unsubscribe:e,redraw:m,render:q.render}}(window);O.setCompletionCallback(I.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 g=function(){a.render(d,x(e))};a.subscribe(d,g);g()}}}(I);var ba=p,P=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},e={},g=0;g<a.length;g++){var q= | ||
a[g].split("="),k=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var h=k.split(/\]\[?|\[/),m=d;-1<k.indexOf("[")&&h.pop();for(var n=0;n<h.length;n++){k=h[n];var l=h[n+1];l=""==l||!isNaN(parseInt(l,10));var p=n===h.length-1;""===k&&(k=h.slice(0,n).join(),null==e[k]&&(e[k]=0),k=e[k]++);null==m[k]&&(m[k]=p?q:l?[]:{});m=m[k]}}return d},ca=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=k(function(){h=null;a()}))}}function g(a,d,e){var c=a.indexOf("?"),g=a.indexOf("#"),h=-1<c?c:-1<g?g:a.length;if(-1<c){c=P(a.slice(c+1,-1<g?g:a.length));for(var k in c)d[k]=c[k]}if(-1<g)for(k in d=P(a.slice(g+1)),d)e[k]=d[k];return a.slice(0,h)}var q="function"===typeof a.history.pushState,k="function"===typeof setImmediate?setImmediate:setTimeout,h,m={prefix:"#!",getPath:function(){switch(m.prefix.charAt(0)){case "#":return d("hash").slice(m.prefix.length); | ||
case "?":return d("search").slice(m.prefix.length)+d("hash");default:return d("pathname").slice(m.prefix.length)+d("search")+d("hash")}},setPath:function(d,e,k){var c={},h={};d=g(d,c,h);if(null!=e){for(var l in e)c[l]=e[l];d=d.replace(/:([^\/]+)/g,function(a,d){delete c[d];return e[d]})}(l=H(c))&&(d+="?"+l);(h=H(h))&&(d+="#"+h);q?(h=k?k.state:null,l=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(h,l,m.prefix+d):a.history.pushState(h,l,m.prefix+d)):a.location.href=m.prefix+d},defineRoutes:function(d, | ||
k,h){function c(){var c=m.getPath(),e={},l=g(c,e,e),n=a.history.state;if(null!=n)for(var q in n)e[q]=n[q];for(var p in d)if(n=new RegExp("^"+p.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),n.test(l)){l.replace(n,function(){for(var a=p.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,1,-2),h=0;h<a.length;h++)e[a[h].replace(/:|\./g,"")]=decodeURIComponent(g[h]);k(d[p],e,c,p)});return}h(c,e)}q?a.onpopstate=e(c):"#"===m.prefix.charAt(0)&&(a.onhashchange=c);c()}};return m};w.route= | ||
function(a,d){var e=ca(a),g=function(a){return a},p,k,h,m,n,l=function(a,l,q){function c(){null!=p&&d.render(a,p(x(k,h.key,h)))}if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var y=function(){c();y=d.redraw};d.subscribe(a,c);var w=function(a){if(a!==l)e.setPath(l,null,{replace:!0});else throw Error("Could not resolve default route "+l);};e.defineRoutes(q,function(a,c,d){var e=n=function(a,l){e===n&&(k=null==l||"function"!==typeof l.view&&"function"!== | ||
typeof l?"div":l,h=c,m=d,n=null,p=(a.render||g).bind(a),y())};a.view||"function"===typeof a?e({},a):a.onmatch?ba.resolve(a.onmatch(c,d)).then(function(c){e(a,c)},w):e(a,"div")},w)};l.set=function(a,d,g){null!=n&&(g=g||{},g.replace=!0);n=null;e.setPath(a,d,g)};l.get=function(){return m};l.prefix=function(a){e.prefix=a};var w=function(a,d){d.dom.setAttribute("href",e.prefix+d.attrs.href);d.dom.onclick=function(c){c.ctrlKey||c.metaKey||c.shiftKey||2===c.which||(c.preventDefault(),c.redraw=!1,c=this.getAttribute("href"), | ||
0===c.indexOf(e.prefix)&&(c=c.slice(e.prefix.length)),l.set(c,void 0,a))}};l.link=function(a){return null==a.tag?w.bind(w,a):w({},a)};l.param=function(a){return"undefined"!==typeof h&&"undefined"!==typeof a?h[a]:h};return l}(window,I);w.withAttr=function(a,d,e){return function(g){d.call(e||this,a in g.currentTarget?g.currentTarget[a]:g.currentTarget.getAttribute(a))}};var da=V(window);w.render=da.render;w.redraw=I.redraw;w.request=O.request;w.jsonp=O.jsonp;w.parseQueryString=P;w.buildQueryString= | ||
H;w.version="2.0.0-rc.0";w.vnode=x;w.PromisePolyfill=p;"undefined"!==typeof module?module.exports=w:window.m=w})(); | ||
!function(){"use strict";function e(e,t,n,r,o,i){return{tag:e,key:t,attrs:n,children:r,text:o,dom:i,domSize:void 0,state:void 0,events:void 0,instance:void 0}}e.normalize=function(t){return Array.isArray(t)?e("[",void 0,void 0,e.normalizeChildren(t),void 0,void 0):null!=t&&"object"!=typeof t?e("#",void 0,void 0,!1===t?"":t,void 0,void 0):t},e.normalizeChildren=function(t){for(var n=[],r=0;r<t.length;r++)n[r]=e.normalize(t[r]);return n};var t=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,n={},r={}.hasOwnProperty;function o(e){for(var t in e)if(r.call(e,t))return!1;return!0}function i(i){if(null==i||"string"!=typeof i&&"function"!=typeof i&&"function"!=typeof i.view)throw Error("The selector must be either a string or a component.");var l,a=arguments[1],u=2;if(null==a?a={}:("object"!=typeof a||null!=a.tag||Array.isArray(a))&&(a={},u=1),arguments.length===u+1)l=arguments[u],Array.isArray(l)||(l=[l]);else for(l=[];u<arguments.length;)l.push(arguments[u++]);return"string"==typeof i?function(t,n,i){var l,a,u=!1,f=r.call(n,"class")?"class":"className",s=n[f];if(!o(t.attrs)&&!o(n)){var c={};for(var d in n)r.call(n,d)&&(c[d]=n[d]);n=c}for(var d in t.attrs)r.call(t.attrs,d)&&"className"!==d&&!r.call(n,d)&&(n[d]=t.attrs[d]);for(var d in null==s&&null==t.attrs.className||(n.className=null!=s?null!=t.attrs.className?t.attrs.className+" "+s:s:null!=t.attrs.className?t.attrs.className:null),"class"===f&&(n.class=null),n)if(r.call(n,d)&&"key"!==d){u=!0;break}return Array.isArray(i)&&1===i.length&&null!=i[0]&&"#"===i[0].tag?a=i[0].children:l=i,e(t.tag,n.key,u?n:null,l,a)}(n[i]||function(e){for(var r,o="div",i=[],l={};r=t.exec(e);){var a=r[1],u=r[2];if(""===a&&""!==u)o=u;else if("#"===a)l.id=u;else if("."===a)i.push(u);else if("["===r[3][0]){var f=r[6];f&&(f=f.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===r[4]?i.push(f):l[r[4]]=""===f?f:f||!0}}return i.length>0&&(l.className=i.join(" ")),n[e]={tag:o,attrs:l}}(i),a,e.normalizeChildren(l)):e(i,a.key,a,l)}i.trust=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)},i.fragment=function(t,n){return e("[",t.key,t,e.normalizeChildren(n),void 0,void 0)};var l=i;if((a=function(e){if(!(this instanceof a))throw new Error("Promise must be called with `new`");if("function"!=typeof e)throw new TypeError("executor must be a function");var t=this,n=[],r=[],o=f(n,!0),i=f(r,!1),l=t._instance={resolvers:n,rejectors:r},u="function"==typeof setImmediate?setImmediate:setTimeout;function f(e,o){return function a(f){var c;try{if(!o||null==f||"object"!=typeof f&&"function"!=typeof f||"function"!=typeof(c=f.then))u(function(){o||0!==e.length||console.error("Possible unhandled promise rejection:",f);for(var t=0;t<e.length;t++)e[t](f);n.length=0,r.length=0,l.state=o,l.retry=function(){a(f)}});else{if(f===t)throw new TypeError("Promise can't be resolved w/ itself");s(c.bind(f))}}catch(e){i(e)}}}function s(e){var t=0;function n(e){return function(n){t++>0||e(n)}}var r=n(i);try{e(n(o),r)}catch(e){r(e)}}s(e)}).prototype.then=function(e,t){var n,r,o=this._instance;function i(e,t,i,l){t.push(function(t){if("function"!=typeof e)i(t);else try{n(e(t))}catch(e){r&&r(e)}}),"function"==typeof o.retry&&l===o.state&&o.retry()}var l=new a(function(e,t){n=e,r=t});return i(e,o.resolvers,n,!0),i(t,o.rejectors,r,!1),l},a.prototype.catch=function(e){return this.then(null,e)},a.prototype.finally=function(e){return this.then(function(t){return a.resolve(e()).then(function(){return t})},function(t){return a.resolve(e()).then(function(){return a.reject(t)})})},a.resolve=function(e){return e instanceof a?e:new a(function(t){t(e)})},a.reject=function(e){return new a(function(t,n){n(e)})},a.all=function(e){return new a(function(t,n){var r=e.length,o=0,i=[];if(0===e.length)t([]);else for(var l=0;l<e.length;l++)!function(l){function a(e){o++,i[l]=e,o===r&&t(i)}null==e[l]||"object"!=typeof e[l]&&"function"!=typeof e[l]||"function"!=typeof e[l].then?a(e[l]):e[l].then(a,n)}(l)})},a.race=function(e){return new a(function(t,n){for(var r=0;r<e.length;r++)e[r].then(t,n)})},"undefined"!=typeof window){void 0===window.Promise?window.Promise=a:window.Promise.prototype.finally||(window.Promise.prototype.finally=a.prototype.finally);var a=window.Promise}else if("undefined"!=typeof global){void 0===global.Promise?global.Promise=a:global.Promise.prototype.finally||(global.Promise.prototype.finally=a.prototype.finally);a=global.Promise}var u=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return"";var t=[];for(var n in e)r(n,e[n]);return t.join("&");function r(e,n){if(Array.isArray(n))for(var o=0;o<n.length;o++)r(e+"["+o+"]",n[o]);else if("[object Object]"===Object.prototype.toString.call(n))for(var o in n)r(e+"["+o+"]",n[o]);else t.push(encodeURIComponent(e)+(null!=n&&""!==n?"="+encodeURIComponent(n):""))}},f=new RegExp("^file://","i"),s=function(e,t){var n,r=0;function o(){var e=0;function t(){0==--e&&"function"==typeof n&&n()}return function n(r){var o=r.then;return r.then=function(){e++;var i=o.apply(r,arguments);return i.then(t,function(n){if(t(),0===e)throw n}),n(i)},r}}function i(e,t){if("string"==typeof e){var n=e;null==(e=t||{}).url&&(e.url=n)}return e}function l(e,t){if(null==t)return e;for(var n=e.match(/:[^\/]+/gi)||[],r=0;r<n.length;r++){var o=n[r].slice(1);null!=t[o]&&(e=e.replace(n[r],t[o]))}return e}function a(e,t){var n=u(t);return""!==n&&(e+=(e.indexOf("?")<0?"?":"&")+n),e}function s(e){try{return""!==e?JSON.parse(e):null}catch(t){throw new Error("Invalid JSON: "+e)}}function c(e){return e.responseText}function d(e,t){if("function"==typeof e){if(!Array.isArray(t))return new e(t);for(var n=0;n<t.length;n++)t[n]=new e(t[n])}return t}return{request:function(n,r){var u=o();n=i(n,r);var v=new t(function(t,r){null==n.method&&(n.method="GET"),n.method=n.method.toUpperCase();var o="GET"!==n.method&&"TRACE"!==n.method&&("boolean"!=typeof n.useBody||n.useBody);"function"!=typeof n.serialize&&(n.serialize="undefined"!=typeof FormData&&n.data instanceof FormData?function(e){return e}:JSON.stringify),"function"!=typeof n.deserialize&&(n.deserialize=s),"function"!=typeof n.extract&&(n.extract=c),n.url=l(n.url,n.data),o?n.data=n.serialize(n.data):n.url=a(n.url,n.data);var i=new e.XMLHttpRequest,u=!1,v=i.abort;for(var h in i.abort=function(){u=!0,v.call(i)},i.open(n.method,n.url,"boolean"!=typeof n.async||n.async,"string"==typeof n.user?n.user:void 0,"string"==typeof n.password?n.password:void 0),n.serialize!==JSON.stringify||!o||n.headers&&n.headers.hasOwnProperty("Content-Type")||i.setRequestHeader("Content-Type","application/json; charset=utf-8"),n.deserialize!==s||n.headers&&n.headers.hasOwnProperty("Accept")||i.setRequestHeader("Accept","application/json, text/*"),n.withCredentials&&(i.withCredentials=n.withCredentials),n.timeout&&(i.timeout=n.timeout),n.responseType&&(i.responseType=n.responseType),n.headers)({}).hasOwnProperty.call(n.headers,h)&&i.setRequestHeader(h,n.headers[h]);"function"==typeof n.config&&(i=n.config(i,n)||i),i.onreadystatechange=function(){if(!u&&4===i.readyState)try{var e=n.extract!==c?n.extract(i,n):n.deserialize(n.extract(i,n));if(n.extract!==c||i.status>=200&&i.status<300||304===i.status||f.test(n.url))t(d(n.type,e));else{var o=new Error(i.responseText);o.code=i.status,o.response=e,r(o)}}catch(e){r(e)}},o&&null!=n.data?i.send(n.data):i.send()});return!0===n.background?v:u(v)},jsonp:function(n,u){var f=o();n=i(n,u);var s=new t(function(t,o){var i=n.callbackName||"_mithril_"+Math.round(1e16*Math.random())+"_"+r++,u=e.document.createElement("script");e[i]=function(r){u.parentNode.removeChild(u),t(d(n.type,r)),delete e[i]},u.onerror=function(){u.parentNode.removeChild(u),o(new Error("JSONP request failed")),delete e[i]},null==n.data&&(n.data={}),n.url=l(n.url,n.data),n.data[n.callbackKey||"callback"]=i,u.src=a(n.url,n.data),e.document.documentElement.appendChild(u)});return!0===n.background?s:f(s)},setCompletionCallback:function(e){n=e}}}(window,a),c=function(t){var n,r=t.document,o={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function i(e){return e.attrs&&e.attrs.xmlns||o[e.tag]}function l(e,t){if(e.state!==t)throw new Error("`vnode.state` must not be modified")}function a(e){var t=e.state;try{return this.apply(t,arguments)}finally{l(e,t)}}function u(e,t,n,r,o,i,l){for(var a=n;a<r;a++){var u=t[a];null!=u&&f(e,u,o,l,i)}}function f(t,n,o,l,s){var d=n.tag;if("string"==typeof d)switch(n.state={},null!=n.attrs&&N(n.attrs,n,o),d){case"#":!function(e,t,n){t.dom=r.createTextNode(t.children),y(e,t.dom,n)}(t,n,s);break;case"<":c(t,n,l,s);break;case"[":!function(e,t,n,o,i){var l=r.createDocumentFragment();if(null!=t.children){var a=t.children;u(l,a,0,a.length,n,null,o)}t.dom=l.firstChild,t.domSize=l.childNodes.length,y(e,l,i)}(t,n,o,l,s);break;default:!function(t,n,o,l,a){var f=n.tag,s=n.attrs,c=s&&s.is,d=(l=i(n)||l)?c?r.createElementNS(l,f,{is:c}):r.createElementNS(l,f):c?r.createElement(f,{is:c}):r.createElement(f);n.dom=d,null!=s&&function(e,t,n){for(var r in t)x(e,r,null,t[r],n)}(n,s,l);if(y(t,d,a),null!=s&&null!=s.contenteditable)g(n);else if(null!=n.text&&(""!==n.text?d.textContent=n.text:n.children=[e("#",void 0,void 0,n.text,void 0,void 0)]),null!=n.children){var v=n.children;u(d,v,0,v.length,o,null,l),"select"===n.tag&&null!=s&&function(e,t){if("value"in t)if(null===t.value)-1!==e.dom.selectedIndex&&(e.dom.value=null);else{var n=""+t.value;e.dom.value===n&&-1!==e.dom.selectedIndex||(e.dom.value=n)}"selectedIndex"in t&&x(e,"selectedIndex",null,t.selectedIndex,void 0)}(n,s)}}(t,n,o,l,s)}else!function(t,n,r,o,i){(function(t,n){var r;if("function"==typeof t.tag.view){if(t.state=Object.create(t.tag),null!=(r=t.state.view).$$reentrantLock$$)return;r.$$reentrantLock$$=!0}else{if(t.state=void 0,null!=(r=t.tag).$$reentrantLock$$)return;r.$$reentrantLock$$=!0,t.state=null!=t.tag.prototype&&"function"==typeof t.tag.prototype.view?new t.tag(t):t.tag(t)}if(null!=t.attrs&&N(t.attrs,t,n),N(t.state,t,n),t.instance=e.normalize(a.call(t.state.view,t)),t.instance===t)throw Error("A view cannot return the vnode it received as argument");r.$$reentrantLock$$=null})(n,r),null!=n.instance?(f(t,n.instance,r,o,i),n.dom=n.instance.dom,n.domSize=null!=n.dom?n.instance.domSize:0):n.domSize=0}(t,n,o,l,s)}var s={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"};function c(e,t,n,o){var i=t.children.match(/^\s*?<(\w+)/im)||[],l=r.createElement(s[i[1]]||"div");"http://www.w3.org/2000/svg"===n?(l.innerHTML='<svg xmlns="http://www.w3.org/2000/svg">'+t.children+"</svg>",l=l.firstChild):l.innerHTML=t.children,t.dom=l.firstChild,t.domSize=l.childNodes.length;for(var a,u=r.createDocumentFragment();a=l.firstChild;)u.appendChild(a);y(e,u,o)}function d(e,t,n,r,o,i){if(t!==n&&(null!=t||null!=n))if(null==t||0===t.length)u(e,n,0,n.length,r,o,i);else if(null==n||0===n.length)w(t,0,t.length);else{for(var l=0,a=0,s=null,c=null;a<t.length;a++)if(null!=t[a]){s=null!=t[a].key;break}for(;l<n.length;l++)if(null!=n[l]){c=null!=n[l].key;break}if(null===c&&null==s)return;if(s!==c)w(t,a,t.length),u(e,n,l,n.length,r,o,i);else if(c){for(var d,g,x,k,C,E=t.length-1,S=n.length-1;E>=a&&S>=l;)if(x=t[E],k=n[S],null==x)E--;else if(null==k)S--;else{if(x.key!==k.key)break;x!==k&&v(e,x,k,r,o,i),null!=k.dom&&(o=k.dom),E--,S--}for(;E>=a&&S>=l;)if(d=t[a],g=n[l],null==d)a++;else if(null==g)l++;else{if(d.key!==g.key)break;a++,l++,d!==g&&v(e,d,g,r,m(t,a,o),i)}for(;E>=a&&S>=l;){if(null==d)a++;else if(null==g)l++;else if(null==x)E--;else if(null==k)S--;else{if(l===S)break;if(d.key!==k.key||x.key!==g.key)break;C=m(t,a,o),y(e,p(x),C),x!==g&&v(e,x,g,r,C,i),++l<=--S&&y(e,p(d),o),d!==k&&v(e,d,k,r,o,i),null!=k.dom&&(o=k.dom),a++,E--}x=t[E],k=n[S],d=t[a],g=n[l]}for(;E>=a&&S>=l;){if(null==x)E--;else if(null==k)S--;else{if(x.key!==k.key)break;x!==k&&v(e,x,k,r,o,i),null!=k.dom&&(o=k.dom),E--,S--}x=t[E],k=n[S]}if(l>S)w(t,a,E+1);else if(a>E)u(e,n,l,S+1,r,o,i);else{var A,z,N=o,j=S-l+1,T=new Array(j),O=0,P=0,$=2147483647,I=0;for(P=0;P<j;P++)T[P]=-1;for(P=S;P>=l;P--)if(null==A&&(A=h(t,a,E+1)),null!=(k=n[P])){var R=A[k.key];null!=R&&($=R<$?R:-1,T[P-l]=R,x=t[R],t[R]=null,x!==k&&v(e,x,k,r,o,i),null!=k.dom&&(o=k.dom),I++)}if(o=N,I!==E-a+1&&w(t,a,E+1),0===I)u(e,n,l,S+1,r,o,i);else if(-1===$)for(O=(z=function(e){var t,n,r=e.slice(),o=[];o.push(0);for(var i=0,l=e.length;i<l;++i)if(-1!==e[i]){var a=o[o.length-1];if(e[a]<e[i])r[i]=a,o.push(i);else{for(t=0,n=o.length-1;t<n;){var u=(t+n)/2|0;e[o[u]]<e[i]?t=u+1:n=u}e[i]<e[o[t]]&&(t>0&&(r[i]=o[t-1]),o[t]=i)}}t=o.length,n=o[t-1];for(;t-- >0;)o[t]=n,n=r[n];return o}(T)).length-1,P=S;P>=l;P--)g=n[P],-1===T[P-l]?f(e,g,r,i,o):z[O]===P-l?O--:y(e,p(g),o),null!=g.dom&&(o=n[P].dom);else for(P=S;P>=l;P--)g=n[P],-1===T[P-l]&&f(e,g,r,i,o),null!=g.dom&&(o=n[P].dom)}}else{var L=t.length<n.length?t.length:n.length;for(l=l<a?l:a;l<L;l++)(d=t[l])===(g=n[l])||null==d&&null==g||(null==d?f(e,g,r,i,m(t,l+1,o)):null==g?b(d):v(e,d,g,r,m(t,l+1,o),i));t.length>L&&w(t,l,t.length),n.length>L&&u(e,n,l,n.length,r,o,i)}}}function v(t,n,r,o,l,u){var s=n.tag;if(s===r.tag){if(r.state=n.state,r.events=n.events,function(e,t){var n,r;null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate&&(n=a.call(e.attrs.onbeforeupdate,e,t));"string"!=typeof e.tag&&"function"==typeof e.state.onbeforeupdate&&(r=a.call(e.state.onbeforeupdate,e,t));if(!(void 0===n&&void 0===r||n||r))return e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,!0;return!1}(r,n))return;if("string"==typeof s)switch(null!=r.attrs&&j(r.attrs,r,o),s){case"#":!function(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children);t.dom=e.dom}(n,r);break;case"<":!function(e,t,n,r,o){t.children!==n.children?(p(t),c(e,n,r,o)):(n.dom=t.dom,n.domSize=t.domSize)}(t,n,r,u,l);break;case"[":!function(e,t,n,r,o,i){d(e,t.children,n.children,r,o,i);var l=0,a=n.children;if(n.dom=null,null!=a){for(var u=0;u<a.length;u++){var f=a[u];null!=f&&null!=f.dom&&(null==n.dom&&(n.dom=f.dom),l+=f.domSize||1)}1!==l&&(n.domSize=l)}}(t,n,r,o,l,u);break;default:!function(t,n,r,o){var l=n.dom=t.dom;o=i(n)||o,"textarea"===n.tag&&(null==n.attrs&&(n.attrs={}),null!=n.text&&(n.attrs.value=n.text,n.text=void 0));(function(e,t,n,r){if(null!=n)for(var o in n)x(e,o,t&&t[o],n[o],r);var i;if(null!=t)for(var o in t)null==(i=t[o])||null!=n&&null!=n[o]||k(e,o,i,r)})(n,t.attrs,n.attrs,o),null!=n.attrs&&null!=n.attrs.contenteditable?g(n):null!=t.text&&null!=n.text&&""!==n.text?t.text.toString()!==n.text.toString()&&(t.dom.firstChild.nodeValue=n.text):(null!=t.text&&(t.children=[e("#",void 0,void 0,t.text,void 0,t.dom.firstChild)]),null!=n.text&&(n.children=[e("#",void 0,void 0,n.text,void 0,void 0)]),d(l,t.children,n.children,r,null,o))}(n,r,o,u)}else!function(t,n,r,o,i,l){if(r.instance=e.normalize(a.call(r.state.view,r)),r.instance===r)throw Error("A view cannot return the vnode it received as argument");null!=r.attrs&&j(r.attrs,r,o);j(r.state,r,o),null!=r.instance?(null==n.instance?f(t,r.instance,o,l,i):v(t,n.instance,r.instance,o,i,l),r.dom=r.instance.dom,r.domSize=r.instance.domSize):null!=n.instance?(b(n.instance),r.dom=void 0,r.domSize=0):(r.dom=n.dom,r.domSize=n.domSize)}(t,n,r,o,l,u)}else b(n),f(t,r,o,u,l)}function h(e,t,n){for(var r=Object.create(null);t<n;t++){var o=e[t];if(null!=o){var i=o.key;null!=i&&(r[i]=t)}}return r}function p(e){var t=e.domSize;if(null!=t||null==e.dom){var n=r.createDocumentFragment();if(t>0){for(var o=e.dom;--t;)n.appendChild(o.nextSibling);n.insertBefore(o,n.firstChild)}return n}return e.dom}function m(e,t,n){for(;t<e.length;t++)if(null!=e[t]&&null!=e[t].dom)return e[t].dom;return n}function y(e,t,n){null!=n?e.insertBefore(t,n):e.appendChild(t)}function g(e){var t=e.children;if(null!=t&&1===t.length&&"<"===t[0].tag){var n=t[0].children;e.dom.innerHTML!==n&&(e.dom.innerHTML=n)}else if(null!=e.text||null!=t&&0!==t.length)throw new Error("Child node of a contenteditable must be trusted")}function w(e,t,n){for(var r=t;r<n;r++){var o=e[r];null!=o&&b(o)}}function b(e){var t,n=1,r=0,o=e.state;e.attrs&&"function"==typeof e.attrs.onbeforeremove&&(null!=(t=a.call(e.attrs.onbeforeremove,e))&&"function"==typeof t.then&&(n++,t.then(i,i)));"string"!=typeof e.tag&&"function"==typeof e.state.onbeforeremove&&(null!=(t=a.call(e.state.onbeforeremove,e))&&"function"==typeof t.then&&(n++,t.then(i,i)));function i(){if(++r===n&&(l(e,o),function e(t){t.attrs&&"function"==typeof t.attrs.onremove&&a.call(t.attrs.onremove,t);if("string"!=typeof t.tag)"function"==typeof t.state.onremove&&a.call(t.state.onremove,t),null!=t.instance&&e(t.instance);else{var n=t.children;if(Array.isArray(n))for(var r=0;r<n.length;r++){var o=n[r];null!=o&&e(o)}}}(e),e.dom)){for(var t=e.dom.parentNode,i=e.domSize||1;--i;)t.removeChild(e.dom.nextSibling);t.removeChild(e.dom)}}i()}function x(e,t,n,o,i){if("key"!==t&&"is"!==t&&null!=o&&!C(t)&&(n!==o||function(e,t){return"value"===t||"checked"===t||"selectedIndex"===t||"selected"===t&&e.dom===r.activeElement||"option"===e.tag&&e.dom.parentNode===r.activeElement}(e,t)||"object"==typeof o)){if("o"===t[0]&&"n"===t[1])return z(e,t,o);if("xlink:"===t.slice(0,6))e.dom.setAttributeNS("http://www.w3.org/1999/xlink",t.slice(6),o);else if("style"===t)S(e.dom,n,o);else if(E(e,t,i)){if("value"===t){if(("input"===e.tag||"textarea"===e.tag)&&e.dom.value===""+o&&e.dom===r.activeElement)return;if("select"===e.tag&&null!==n&&e.dom.value===""+o)return;if("option"===e.tag&&null!==n&&e.dom.value===""+o)return}"input"===e.tag&&"type"===t?e.dom.setAttribute(t,o):e.dom[t]=o}else"boolean"==typeof o?o?e.dom.setAttribute(t,""):e.dom.removeAttribute(t):e.dom.setAttribute("className"===t?"class":t,o)}}function k(e,t,n,r){if("key"!==t&&"is"!==t&&null!=n&&!C(t))if("o"!==t[0]||"n"!==t[1]||C(t))if("style"===t)S(e.dom,n,null);else if(!E(e,t,r)||"className"===t||"option"===e.tag&&"value"===t||"input"===e.tag&&"type"===t){var o=t.indexOf(":");-1!==o&&(t=t.slice(o+1)),!1!==n&&e.dom.removeAttribute("className"===t?"class":t)}else e.dom[t]=null;else z(e,t,void 0)}function C(e){return"oninit"===e||"oncreate"===e||"onupdate"===e||"onremove"===e||"onbeforeremove"===e||"onbeforeupdate"===e}function E(e,t,n){return void 0===n&&(e.tag.indexOf("-")>-1||null!=e.attrs&&e.attrs.is||"href"!==t&&"list"!==t&&"form"!==t&&"width"!==t&&"height"!==t)&&t in e.dom}function S(e,t,n){if(null==t||null==n||"object"!=typeof t||"object"!=typeof n||n===t)if(t===n&&(e.style.cssText="",t=null),null==n)e.style.cssText="";else if("string"==typeof n)e.style.cssText=n;else for(var r in"string"==typeof t&&(e.style.cssText=""),n)e.style[r]=n[r];else{for(var r in n)n[r]!==t[r]&&(e.style[r]=n[r]);for(var r in t)r in n||(e.style[r]="")}}function A(){}function z(e,t,n){if(null!=e.events){if(e.events[t]===n)return;null==n||"function"!=typeof n&&"object"!=typeof n?(null!=e.events[t]&&e.dom.removeEventListener(t.slice(2),e.events,!1),e.events[t]=void 0):(null==e.events[t]&&e.dom.addEventListener(t.slice(2),e.events,!1),e.events[t]=n)}else null==n||"function"!=typeof n&&"object"!=typeof n||(e.events=new A,e.dom.addEventListener(t.slice(2),e.events,!1),e.events[t]=n)}function N(e,t,n){"function"==typeof e.oninit&&a.call(e.oninit,t),"function"==typeof e.oncreate&&n.push(a.bind(e.oncreate,t))}function j(e,t,n){"function"==typeof e.onupdate&&n.push(a.bind(e.onupdate,t))}return A.prototype=Object.create(null),A.prototype.handleEvent=function(e){var t,r=this["on"+e.type];"function"==typeof r?t=r.call(e.target,e):"function"==typeof r.handleEvent&&r.handleEvent(e),"function"==typeof n&&n.call(e.target,e),!1===t&&(e.preventDefault(),e.stopPropagation())},{render:function(t,n){if(!t)throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var o=[],i=r.activeElement,l=t.namespaceURI;null==t.vnodes&&(t.textContent=""),n=e.normalizeChildren(Array.isArray(n)?n:[n]),d(t,t.vnodes,n,o,null,"http://www.w3.org/1999/xhtml"===l?void 0:l),t.vnodes=n,null!=i&&r.activeElement!==i&&"function"==typeof i.focus&&i.focus();for(var a=0;a<o.length;a++)o[a]()},setEventCallback:function(e){return n=e}}};var d=function(e,t){var n=c(e);n.setEventCallback(function(e){!1===e.redraw?e.redraw=void 0:a()});var r=[],o=!1;function i(e){var t=r.indexOf(e);t>-1&&r.splice(t,2)}function l(){if(o)throw new Error("Nested m.redraw.sync() call");o=!0;for(var e=1;e<r.length;e+=2)try{r[e]()}catch(e){"undefined"!=typeof console&&console.error(e)}o=!1}var a=(t||function(e){var t=0,n=null,r="function"==typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var o=Date.now()-t;null===n&&(n=r(function(){n=null,e(),t=Date.now()},16-o))}})(l);return a.sync=l,{subscribe:function(e,t){i(e),r.push(e,t)},unsubscribe:i,redraw:a,render:n.render}}(window);s.setCompletionCallback(d.redraw);var v;l.mount=(v=d,function(t,n){if(null===n)return v.render(t,[]),void v.unsubscribe(t);if(null==n.view&&"function"!=typeof n)throw new Error("m.mount(element, component) expects a component, not a vnode");var r=function(){v.render(t,e(n))};v.subscribe(t,r),r()});var h=a,p=function(e){if(""===e||null==e)return{};"?"===e.charAt(0)&&(e=e.slice(1));for(var t=e.split("&"),n={},r={},o=0;o<t.length;o++){var i=t[o].split("="),l=decodeURIComponent(i[0]),a=2===i.length?decodeURIComponent(i[1]):"";"true"===a?a=!0:"false"===a&&(a=!1);var u=l.split(/\]\[?|\[/),f=n;l.indexOf("[")>-1&&u.pop();for(var s=0;s<u.length;s++){var c=u[s],d=u[s+1],v=""==d||!isNaN(parseInt(d,10)),h=s===u.length-1;if(""===c)null==r[l=u.slice(0,s).join()]&&(r[l]=0),c=r[l]++;null==f[c]&&(f[c]=h?a:v?[]:{}),f=f[c]}}return n},m=function(e){var t,n="function"==typeof e.history.pushState,r="function"==typeof setImmediate?setImmediate:setTimeout;function o(t){var n=e.location[t].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);return"pathname"===t&&"/"!==n[0]&&(n="/"+n),n}function i(e,t,n){var r=e.indexOf("?"),o=e.indexOf("#"),i=r>-1?r:o>-1?o:e.length;if(r>-1){var l=o>-1?o:e.length,a=p(e.slice(r+1,l));for(var u in a)t[u]=a[u]}if(o>-1){var f=p(e.slice(o+1));for(var u in f)n[u]=f[u]}return e.slice(0,i)}var l={prefix:"#!",getPath:function(){switch(l.prefix.charAt(0)){case"#":return o("hash").slice(l.prefix.length);case"?":return o("search").slice(l.prefix.length)+o("hash");default:return o("pathname").slice(l.prefix.length)+o("search")+o("hash")}},setPath:function(t,r,o){var a={},f={};if(t=i(t,a,f),null!=r){for(var s in r)a[s]=r[s];t=t.replace(/:([^\/]+)/g,function(e,t){return delete a[t],r[t]})}var c=u(a);c&&(t+="?"+c);var d=u(f);if(d&&(t+="#"+d),n){var v=o?o.state:null,h=o?o.title:null;e.onpopstate(),o&&o.replace?e.history.replaceState(v,h,l.prefix+t):e.history.pushState(v,h,l.prefix+t)}else e.location.href=l.prefix+t}};return l.defineRoutes=function(o,a,u){function f(){var t=l.getPath(),n={},r=i(t,n,n),f=e.history.state;if(null!=f)for(var s in f)n[s]=f[s];for(var c in o){var d=new RegExp("^"+c.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(d.test(r))return void r.replace(d,function(){for(var e=c.match(/:[^\/]+/g)||[],r=[].slice.call(arguments,1,-2),i=0;i<e.length;i++)n[e[i].replace(/:|\./g,"")]=decodeURIComponent(r[i]);a(o[c],n,t,c)})}u(t,n)}var s;n?e.onpopstate=(s=f,function(){null==t&&(t=r(function(){t=null,s()}))}):"#"===l.prefix.charAt(0)&&(e.onhashchange=f),f()},l};l.route=function(t,n){var r,o,i,l,a,u=m(t),f=function(t,f,s){if(null==t)throw new Error("Ensure the DOM element that was passed to `m.route` is not undefined");function c(){null!=r&&n.render(t,r(e(o,i.key,i)))}var d=function(){c(),d=n.redraw};n.subscribe(t,c);var v=function(e){if(e===f)throw new Error("Could not resolve default route "+f);u.setPath(f,null,{replace:!0})};u.defineRoutes(s,function(e,t,n){var u=a=function(e,f){u===a&&(o=null==f||"function"!=typeof f.view&&"function"!=typeof f?"div":f,i=t,l=n,a=null,r=(e.render||function(e){return e}).bind(e),d())};e.view||"function"==typeof e?u({},e):e.onmatch?h.resolve(e.onmatch(t,n)).then(function(t){u(e,t)},v):u(e,"div")},v)};f.set=function(e,t,n){null!=a&&((n=n||{}).replace=!0),a=null,u.setPath(e,t,n)},f.get=function(){return l},f.prefix=function(e){u.prefix=e};var s=function(e,t){t.dom.setAttribute("href",u.prefix+t.attrs.href),t.dom.onclick=function(t){if(!(t.ctrlKey||t.metaKey||t.shiftKey||2===t.which)){t.preventDefault(),t.redraw=!1;var n=this.getAttribute("href");0===n.indexOf(u.prefix)&&(n=n.slice(u.prefix.length)),f.set(n,void 0,e)}}};return f.link=function(e){return null==e.tag?s.bind(s,e):s({},e)},f.param=function(e){return void 0!==i&&void 0!==e?i[e]:i},f}(window,d),l.withAttr=function(e,t,n){return function(r){t.call(n||this,e in r.currentTarget?r.currentTarget[e]:r.currentTarget.getAttribute(e))}},l.prop=function(e){return{get:function(){return e},toJSON:function(){return e},set:function(t){return e=t}}};var y=c(window);l.render=y.render,l.redraw=d.redraw,l.request=s.request,l.jsonp=s.jsonp,l.parseQueryString=p,l.buildQueryString=u,l.version="2.0.0-rc.1",l.vnode=e,l.PromisePolyfill=a,"undefined"!=typeof module?module.exports=l:window.m=l}(); |
{ | ||
"name": "mithril", | ||
"version": "2.0.0-rc.0", | ||
"version": "2.0.0-rc.1", | ||
"description": "A framework for building brilliant applications", | ||
@@ -39,3 +39,4 @@ "author": "Leo Horie", | ||
"marked": "^0.3.19", | ||
"pinpoint": "^1.1.0" | ||
"pinpoint": "^1.1.0", | ||
"uglify-es": "^3.3.9" | ||
}, | ||
@@ -42,0 +43,0 @@ "bin": { |
@@ -21,3 +21,3 @@ mithril.js [](https://www.npmjs.com/package/mithril) [](https://www.npmjs.com/package/mithril) [](https://www.npmjs.com/package/mithril) | ||
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.87 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.89 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box. | ||
@@ -24,0 +24,0 @@ Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍. |
@@ -868,4 +868,4 @@ "use strict" | ||
if (!Array.isArray(vnodes)) vnodes = [vnodes] | ||
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace) | ||
vnodes = Vnode.normalizeChildren(Array.isArray(vnodes) ? vnodes : [vnodes]) | ||
updateNodes(dom, dom.vnodes, vnodes, hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace) | ||
dom.vnodes = vnodes | ||
@@ -872,0 +872,0 @@ // document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement |
@@ -15,2 +15,28 @@ "use strict" | ||
o("renders plain text", function() { | ||
render(root, "a") | ||
o(root.childNodes.length).equals(1) | ||
o(root.childNodes[0].nodeValue).equals("a") | ||
}) | ||
o("updates plain text", function() { | ||
render(root, "a") | ||
render(root, "b") | ||
o(root.childNodes.length).equals(1) | ||
o(root.childNodes[0].nodeValue).equals("b") | ||
}) | ||
o("renders a number", function() { | ||
render(root, 1) | ||
o(root.childNodes.length).equals(1) | ||
o(root.childNodes[0].nodeValue).equals("1") | ||
}) | ||
o("updates a number", function() { | ||
render(root, 1) | ||
render(root, 2) | ||
o(root.childNodes.length).equals(1) | ||
o(root.childNodes[0].nodeValue).equals("2") | ||
}) | ||
o("overwrites existing content", function() { | ||
@@ -17,0 +43,0 @@ var vnodes = [] |
@@ -11,3 +11,3 @@ "use strict" | ||
} | ||
Vnode.normalizeChildren = function normalizeChildren(input) { | ||
Vnode.normalizeChildren = function(input) { | ||
var children = [] | ||
@@ -14,0 +14,0 @@ for (var i = 0; i < input.length; i++) { |
Sorry, the diff of this file is not supported yet
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1327916
0.31%209
1.46%14
-12.5%12
9.09%21036
-0.38%