Comparing version 0.1.26 to 0.1.27
164
mithril.js
@@ -36,3 +36,3 @@ var m = (function app(window, undefined) { | ||
var args = [].slice.call(arguments); | ||
var hasAttrs = args[1] != null && type.call(args[1]) == OBJECT && !("tag" in args[1]) && !("subtree" in args[1]); | ||
var hasAttrs = args[1] != null && type.call(args[1]) === OBJECT && !("tag" in args[1]) && !("subtree" in args[1]); | ||
var attrs = hasAttrs ? args[1] : {}; | ||
@@ -44,6 +44,6 @@ var classAttrName = "class" in attrs ? "class" : "className"; | ||
while (match = parser.exec(args[0])) { | ||
if (match[1] == "" && match[2]) cell.tag = match[2]; | ||
else if (match[1] == "#") cell.attrs.id = match[2]; | ||
else if (match[1] == ".") classes.push(match[2]); | ||
else if (match[3][0] == "[") { | ||
if (match[1] === "" && match[2]) cell.tag = match[2]; | ||
else if (match[1] === "#") cell.attrs.id = match[2]; | ||
else if (match[1] === ".") classes.push(match[2]); | ||
else if (match[3][0] === "[") { | ||
var pair = attrParser.exec(match[3]); | ||
@@ -57,3 +57,3 @@ cell.attrs[pair[1]] = pair[3] || (pair[2] ? "" :true) | ||
var children = hasAttrs ? args[2] : args[1]; | ||
if (type.call(children) == ARRAY) { | ||
if (type.call(children) === ARRAY) { | ||
cell.children = children | ||
@@ -66,3 +66,3 @@ } | ||
for (var attrName in attrs) { | ||
if (attrName == classAttrName) cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName]; | ||
if (attrName === classAttrName) cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName]; | ||
else cell.attrs[attrName] = attrs[attrName] | ||
@@ -98,10 +98,10 @@ } | ||
//- it simplifies diffing code | ||
if (data == null) data = ""; | ||
if (data == null || data.toString() == null) data = ""; | ||
if (data.subtree === "retain") return cached; | ||
var cachedType = type.call(cached), dataType = type.call(data); | ||
if (cached == null || cachedType != dataType) { | ||
if (cached == null || cachedType !== dataType) { | ||
if (cached != null) { | ||
if (parentCache && parentCache.nodes) { | ||
var offset = index - parentIndex; | ||
var end = offset + (dataType == ARRAY ? data : cached.nodes).length; | ||
var end = offset + (dataType === ARRAY ? data : cached.nodes).length; | ||
clear(parentCache.nodes.slice(offset, end), parentCache.slice(offset, end)) | ||
@@ -116,6 +116,6 @@ } | ||
if (dataType == ARRAY) { | ||
if (dataType === ARRAY) { | ||
//recursively flatten array | ||
for (var i = 0; i < data.length; i++) { | ||
if (type.call(data[i]) == ARRAY) { | ||
for (var i = 0, len = data.length; i < len; i++) { | ||
if (type.call(data[i]) === ARRAY) { | ||
data = data.concat.apply([], data); | ||
@@ -136,3 +136,3 @@ i-- //check current index again and flatten until there are no more nested arrays at that index | ||
var existing = {}, unkeyed = [], shouldMaintainIdentities = false; | ||
for (var i = 0; i < cached.length; i++) { | ||
for (var i = 0, len = cached.length; i < len; i++) { | ||
if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) { | ||
@@ -144,3 +144,4 @@ shouldMaintainIdentities = true; | ||
if (shouldMaintainIdentities) { | ||
for (var i = 0; i < data.length; i++) { | ||
if (data.indexOf(null) > -1) data = data.filter(function(x) {return x != null}) | ||
for (var i = 0, len = data.length; i < len; i++) { | ||
if (data[i] && data[i].attrs) { | ||
@@ -165,7 +166,7 @@ if (data[i].attrs.key != null) { | ||
for (var i = 0, change; change = changes[i]; i++) { | ||
if (change.action == DELETION) { | ||
if (change.action === DELETION) { | ||
clear(cached[change.index].nodes, cached[change.index]); | ||
newCached.splice(change.index, 1) | ||
} | ||
if (change.action == INSERTION) { | ||
if (change.action === INSERTION) { | ||
var dummy = $document.createElement("div"); | ||
@@ -177,3 +178,3 @@ dummy.key = data[change.index].attrs.key; | ||
if (change.action == MOVE) { | ||
if (change.action === MOVE) { | ||
if (parentElement.childNodes[change.index] !== change.element && change.element !== null) { | ||
@@ -185,3 +186,3 @@ parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null) | ||
} | ||
for (var i = 0; i < unkeyed.length; i++) { | ||
for (var i = 0, len = unkeyed.length; i < len; i++) { | ||
var change = unkeyed[i]; | ||
@@ -197,3 +198,3 @@ parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null); | ||
for (var i = 0, cacheCount = 0; i < data.length; i++) { | ||
for (var i = 0, cacheCount = 0, len = data.length; i < len; i++) { | ||
//diff each item in the array | ||
@@ -209,3 +210,3 @@ var item = build(parentElement, parentTag, cached, index, data[i], cached[cacheCount], shouldReattach, index + subArrayCount || subArrayCount, editable, namespace, configs); | ||
} | ||
else subArrayCount += type.call(item) == ARRAY ? item.length : 1; | ||
else subArrayCount += type.call(item) === ARRAY ? item.length : 1; | ||
cached[cacheCount++] = item | ||
@@ -217,3 +218,3 @@ } | ||
//update the list of DOM nodes by collecting the nodes from each item | ||
for (var i = 0; i < data.length; i++) { | ||
for (var i = 0, len = data.length; i < len; i++) { | ||
if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes) | ||
@@ -230,3 +231,3 @@ } | ||
} | ||
else if (data != null && dataType == OBJECT) { | ||
else if (data != null && dataType === OBJECT) { | ||
if (!data.attrs) data.attrs = {}; | ||
@@ -240,3 +241,3 @@ if (!cached.attrs) cached.attrs = {}; | ||
if (cached.nodes.length) clear(cached.nodes); | ||
if (cached.configContext && typeof cached.configContext.onunload == FUNCTION) cached.configContext.onunload() | ||
if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) cached.configContext.onunload() | ||
} | ||
@@ -263,3 +264,3 @@ if (type.call(data.tag) != STRING) return; | ||
//edge case: setting value on <select> doesn't work before children exist, so set it again after children have been created | ||
if (data.tag == "select" && data.attrs.value) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace); | ||
if (data.tag === "select" && data.attrs.value) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace); | ||
parentElement.insertBefore(node, parentElement.childNodes[index] || null) | ||
@@ -275,3 +276,3 @@ } | ||
//schedule configs to be called. They are called after `build` finishes running | ||
if (typeof data.attrs["config"] == FUNCTION) { | ||
if (typeof data.attrs["config"] === FUNCTION) { | ||
var context = cached.configContext = cached.configContext || {}; | ||
@@ -315,3 +316,3 @@ | ||
else { | ||
if (nodes[0].nodeType == 1 || nodes.length > 1) { //was a trusted string | ||
if (nodes[0].nodeType === 1 || nodes.length > 1) { //was a trusted string | ||
clear(cached.nodes, cached); | ||
@@ -344,7 +345,7 @@ nodes = [$document.createTextNode(data)] | ||
//hook event handlers to the auto-redrawing system | ||
else if (typeof dataAttr == FUNCTION && attrName.indexOf("on") == 0) { | ||
else if (typeof dataAttr === FUNCTION && attrName.indexOf("on") === 0) { | ||
node[attrName] = autoredraw(dataAttr, node) | ||
} | ||
//handle `style: {...}` | ||
else if (attrName === "style" && dataAttr != null && type.call(dataAttr) == OBJECT) { | ||
else if (attrName === "style" && dataAttr != null && type.call(dataAttr) === OBJECT) { | ||
for (var rule in dataAttr) { | ||
@@ -366,5 +367,5 @@ if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] | ||
//- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js | ||
else if (attrName in node && !(attrName == "list" || attrName == "style" || attrName == "form" || attrName == "type")) { | ||
else if (attrName in node && !(attrName === "list" || attrName === "style" || attrName === "form" || attrName === "type")) { | ||
//#348 don't set the value if not needed otherwise cursor placement breaks in Chrome | ||
if (node[attrName] != dataAttr) node[attrName] = dataAttr | ||
if (attrName != "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr | ||
} | ||
@@ -397,6 +398,6 @@ else node.setAttribute(attrName, dataAttr) | ||
function unload(cached) { | ||
if (cached.configContext && typeof cached.configContext.onunload == FUNCTION) cached.configContext.onunload(); | ||
if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) cached.configContext.onunload(); | ||
if (cached.children) { | ||
if (type.call(cached.children) == ARRAY) { | ||
for (var i = 0; i < cached.children.length; i++) unload(cached.children[i]) | ||
if (type.call(cached.children) === ARRAY) { | ||
for (var i = 0, child; child = cached.children[i]; i++) unload(child) | ||
} | ||
@@ -433,3 +434,3 @@ else if (cached.children.tag) unload(cached.children) | ||
finally { | ||
m.endComputation() | ||
endFirstComputation() | ||
} | ||
@@ -459,4 +460,4 @@ } | ||
var id = getCellCacheKey(root); | ||
var isDocumentRoot = root == $document; | ||
var node = isDocumentRoot || root == $document.documentElement ? documentNode : root; | ||
var isDocumentRoot = root === $document; | ||
var node = isDocumentRoot || root === $document.documentElement ? documentNode : root; | ||
if (isDocumentRoot && cell.tag != "html") cell = {tag: "html", attrs: {}, children: cell}; | ||
@@ -466,3 +467,3 @@ if (cellCache[id] === undefined) clear(node.childNodes); | ||
cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs); | ||
for (var i = 0; i < configs.length; i++) configs[i]() | ||
for (var i = 0, len = configs.length; i < len; i++) configs[i]() | ||
}; | ||
@@ -495,3 +496,3 @@ function getCellCacheKey(element) { | ||
//note: using non-strict equality check here because we're checking if store is null OR undefined | ||
if (((store != null && type.call(store) == OBJECT) || typeof store == FUNCTION) && typeof store.then == FUNCTION) { | ||
if (((store != null && type.call(store) === OBJECT) || typeof store === FUNCTION) && typeof store.then === FUNCTION) { | ||
return propify(store) | ||
@@ -509,3 +510,3 @@ } | ||
var isPrevented = false; | ||
if (controllers[index] && typeof controllers[index].onunload == FUNCTION) { | ||
if (controllers[index] && typeof controllers[index].onunload === FUNCTION) { | ||
var event = { | ||
@@ -524,7 +525,7 @@ preventDefault: function() {isPrevented = true} | ||
//this conditional ensures only the last recursive m.module call is applied | ||
if (currentModule == topModule) { | ||
if (currentModule === topModule) { | ||
controllers[index] = controller; | ||
modules[index] = module | ||
} | ||
m.endComputation(); | ||
endFirstComputation(); | ||
return controllers[index] | ||
@@ -539,3 +540,3 @@ } | ||
//when rAF: always reschedule redraw | ||
if (new Date - lastRedrawCallTime > FRAME_BUDGET || $requestAnimationFrame == window.requestAnimationFrame) { | ||
if (new Date - lastRedrawCallTime > FRAME_BUDGET || $requestAnimationFrame === window.requestAnimationFrame) { | ||
if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId); | ||
@@ -552,6 +553,6 @@ lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET) | ||
function redraw() { | ||
var mode = m.redraw.strategy(); | ||
for (var i = 0; i < roots.length; i++) { | ||
if (controllers[i] && mode != "none") { | ||
m.render(roots[i], modules[i].view(controllers[i]), mode == "all") | ||
var forceRedraw = m.redraw.strategy() === "all"; | ||
for (var i = 0, root; root = roots[i]; i++) { | ||
if (controllers[i]) { | ||
m.render(root, modules[i].view(controllers[i]), forceRedraw) | ||
} | ||
@@ -573,4 +574,11 @@ } | ||
pendingRequests = Math.max(pendingRequests - 1, 0); | ||
if (pendingRequests == 0) m.redraw() | ||
if (pendingRequests === 0) m.redraw() | ||
}; | ||
var endFirstComputation = function() { | ||
if (m.redraw.strategy() == "none") { | ||
pendingRequests-- | ||
m.redraw.strategy("diff") | ||
} | ||
else m.endComputation(); | ||
} | ||
@@ -592,3 +600,3 @@ m.withAttr = function(prop, withAttrCallback) { | ||
//m.route(el, defaultRoute, routes) | ||
else if (arguments.length === 3 && type.call(arguments[1]) == STRING) { | ||
else if (arguments.length === 3 && type.call(arguments[1]) === STRING) { | ||
var root = arguments[0], defaultRoute = arguments[1], router = arguments[2]; | ||
@@ -601,3 +609,3 @@ redirect = function(source) { | ||
}; | ||
var listener = m.route.mode == "hash" ? "onhashchange" : "onpopstate"; | ||
var listener = m.route.mode === "hash" ? "onhashchange" : "onpopstate"; | ||
window[listener] = function() { | ||
@@ -621,3 +629,3 @@ if (currentRoute != normalizeRoute($location[m.route.mode])) { | ||
//m.route(route, params) | ||
else if (type.call(arguments[0]) == STRING) { | ||
else if (type.call(arguments[0]) === STRING) { | ||
currentRoute = arguments[0]; | ||
@@ -632,3 +640,3 @@ var args = arguments[1] || {} | ||
var shouldReplaceHistoryEntry = (arguments.length == 3 ? arguments[2] : arguments[1]) === true; | ||
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true; | ||
@@ -661,3 +669,3 @@ if (window.history.pushState) { | ||
for (var route in router) { | ||
if (route == path) { | ||
if (route === path) { | ||
m.module(root, router[route]); | ||
@@ -673,3 +681,3 @@ return true | ||
var values = [].slice.call(arguments, 1, -2); | ||
for (var i = 0; i < keys.length; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i]) | ||
for (var i = 0, len = keys.length; i < len; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i]) | ||
m.module(root, router[route]) | ||
@@ -683,7 +691,7 @@ }); | ||
e = e || event; | ||
if (e.ctrlKey || e.metaKey || e.which == 2) return; | ||
if (e.ctrlKey || e.metaKey || e.which === 2) return; | ||
if (e.preventDefault) e.preventDefault(); | ||
else e.returnValue = false; | ||
var currentTarget = e.currentTarget || this; | ||
var args = m.route.mode == "pathname" && currentTarget.search ? parseQueryString(currentTarget.search.slice(1)) : {}; | ||
var args = m.route.mode === "pathname" && currentTarget.search ? parseQueryString(currentTarget.search.slice(1)) : {}; | ||
m.route(currentTarget[m.route.mode].slice(modes[m.route.mode].length), args) | ||
@@ -699,3 +707,3 @@ } | ||
var key = prefix ? prefix + "[" + prop + "]" : prop, value = object[prop]; | ||
str.push(value != null && type.call(value) == OBJECT ? buildQueryString(value, key) : encodeURIComponent(key) + "=" + encodeURIComponent(value)) | ||
str.push(value != null && type.call(value) === OBJECT ? buildQueryString(value, key) : encodeURIComponent(key) + "=" + encodeURIComponent(value)) | ||
} | ||
@@ -706,3 +714,3 @@ return str.join("&") | ||
var pairs = str.split("&"), params = {}; | ||
for (var i = 0; i < pairs.length; i++) { | ||
for (var i = 0, len = pairs.length; i < len; i++) { | ||
var pair = pairs[i].split("="); | ||
@@ -767,6 +775,6 @@ params[decodeSpace(pair[0])] = pair[1] ? decodeSpace(pair[1]) : "" | ||
var deferred = new Deferred(successCallback, failureCallback); | ||
if (state == RESOLVED) { | ||
if (state === RESOLVED) { | ||
deferred.resolve(promiseValue) | ||
} | ||
else if (state == REJECTED) { | ||
else if (state === REJECTED) { | ||
deferred.reject(promiseValue) | ||
@@ -783,3 +791,3 @@ } | ||
next.map(function(deferred) { | ||
state == RESOLVED && deferred.resolve(promiseValue) || deferred.reject(promiseValue) | ||
state === RESOLVED && deferred.resolve(promiseValue) || deferred.reject(promiseValue) | ||
}) | ||
@@ -789,3 +797,3 @@ } | ||
function thennable(then, successCallback, failureCallback, notThennableCallback) { | ||
if (((promiseValue != null && type.call(promiseValue) == OBJECT) || typeof promiseValue == FUNCTION) && typeof then == FUNCTION) { | ||
if (((promiseValue != null && type.call(promiseValue) === OBJECT) || typeof promiseValue === FUNCTION) && typeof then === FUNCTION) { | ||
try { | ||
@@ -834,6 +842,6 @@ // count protects against abuse calls from spec checker | ||
try { | ||
if (state == RESOLVING && typeof successCallback == FUNCTION) { | ||
if (state === RESOLVING && typeof successCallback === FUNCTION) { | ||
promiseValue = successCallback(promiseValue) | ||
} | ||
else if (state == REJECTING && typeof failureCallback == "function") { | ||
else if (state === REJECTING && typeof failureCallback === "function") { | ||
promiseValue = failureCallback(promiseValue); | ||
@@ -849,3 +857,3 @@ state = RESOLVING | ||
if (promiseValue == self) { | ||
if (promiseValue === self) { | ||
promiseValue = TypeError(); | ||
@@ -858,3 +866,3 @@ finish() | ||
}, finish, function () { | ||
finish(state == RESOLVING && RESOLVED) | ||
finish(state === RESOLVING && RESOLVED) | ||
}) | ||
@@ -866,3 +874,3 @@ } | ||
m.deferred.onerror = function(e) { | ||
if (type.call(e) == "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e | ||
if (type.call(e) === "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e | ||
}; | ||
@@ -876,3 +884,3 @@ | ||
if (!resolved) method = "reject"; | ||
if (--outstanding == 0) { | ||
if (--outstanding === 0) { | ||
deferred.promise(results); | ||
@@ -950,9 +958,9 @@ deferred[method](results) | ||
}; | ||
if (options.serialize == JSON.stringify && options.data && options.method != "GET") { | ||
if (options.serialize === JSON.stringify && options.data && options.method !== "GET") { | ||
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8") | ||
} | ||
if (options.deserialize == JSON.parse) { | ||
if (options.deserialize === JSON.parse) { | ||
xhr.setRequestHeader("Accept", "application/json, text/*"); | ||
} | ||
if (typeof options.config == FUNCTION) { | ||
if (typeof options.config === FUNCTION) { | ||
var maybeXhr = options.config(xhr, options); | ||
@@ -962,3 +970,3 @@ if (maybeXhr != null) xhr = maybeXhr | ||
var data = options.method == "GET" || !options.data ? "" : options.data | ||
var data = options.method === "GET" || !options.data ? "" : options.data | ||
if (data && (type.call(data) != STRING && data.constructor != window.FormData)) { | ||
@@ -972,3 +980,3 @@ throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`"; | ||
function bindData(xhrOptions, data, serialize) { | ||
if (xhrOptions.method == "GET" && xhrOptions.dataType != "jsonp") { | ||
if (xhrOptions.method === "GET" && xhrOptions.dataType != "jsonp") { | ||
var prefix = xhrOptions.url.indexOf("?") < 0 ? "?" : "&"; | ||
@@ -1007,6 +1015,6 @@ var querystring = buildQueryString(data); | ||
e = e || event; | ||
var unwrap = (e.type == "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity; | ||
var unwrap = (e.type === "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity; | ||
var response = unwrap(deserialize(extract(e.target, xhrOptions))); | ||
if (e.type == "load") { | ||
if (type.call(response) == ARRAY && xhrOptions.type) { | ||
if (e.type === "load") { | ||
if (type.call(response) === ARRAY && xhrOptions.type) { | ||
for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i]) | ||
@@ -1016,3 +1024,3 @@ } | ||
} | ||
deferred[e.type == "load" ? "resolve" : "reject"](response) | ||
deferred[e.type === "load" ? "resolve" : "reject"](response) | ||
} | ||
@@ -1042,2 +1050,2 @@ catch (e) { | ||
if (typeof module != "undefined" && module !== null && module.exports) module.exports = m; | ||
else if (typeof define == "function" && define.amd) define(function() {return m}); | ||
else if (typeof define === "function" && define.amd) define(function() {return m}); |
/* | ||
Mithril v0.1.26 | ||
Mithril v0.1.27 | ||
http://github.com/lhorie/mithril.js | ||
@@ -7,3 +7,3 @@ (c) Leo Horie | ||
*/ | ||
var m=function a(b,c){function d(a){C=a.document,D=a.location,F=a.cancelAnimationFrame||a.clearTimeout,E=a.requestAnimationFrame||a.setTimeout}function e(){var a,b=[].slice.call(arguments),c=!(null==b[1]||K.call(b[1])!=G||"tag"in b[1]||"subtree"in b[1]),d=c?b[1]:{},e="class"in d?"class":"className",f={tag:"div",attrs:{}},g=[];if(K.call(b[0])!=I)throw new Error("selector in m(selector, attrs, children) should be a string");for(;a=L.exec(b[0]);)if(""==a[1]&&a[2])f.tag=a[2];else if("#"==a[1])f.attrs.id=a[2];else if("."==a[1])g.push(a[2]);else if("["==a[3][0]){var h=M.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=K.call(i)==H?i:b.slice(c?2:1);for(var j in d)f.attrs[j]=j==e?(f.attrs[j]||"")+" "+d[j]:d[j];return f}function f(a,b,d,e,i,k,l,m,n,o,p){if(null==i&&(i=""),"retain"===i.subtree)return k;var q=K.call(k),r=K.call(i);if(null==k||q!=r){if(null!=k)if(d&&d.nodes){var s=m-e,t=s+(r==H?i:k.nodes).length;h(d.nodes.slice(s,t),d.slice(s,t))}else k.nodes&&h(k.nodes,k);k=new i.constructor,k.tag&&(k={}),k.nodes=[]}if(r==H){for(var u=0;u<i.length;u++)K.call(i[u])==H&&(i=i.concat.apply([],i),u--);for(var v=[],w=k.length===i.length,x=0,y=1,z=2,A=3,B={},D=[],E=!1,u=0;u<k.length;u++)k[u]&&k[u].attrs&&null!=k[u].attrs.key&&(E=!0,B[k[u].attrs.key]={action:y,index:u});if(E){for(var u=0;u<i.length;u++)if(i[u]&&i[u].attrs)if(null!=i[u].attrs.key){var F=i[u].attrs.key;B[F]=B[F]?{action:A,index:u,from:B[F].index,element:a.childNodes[B[F].index]||C.createElement("div")}:{action:z,index:u}}else D.push({index:u,element:a.childNodes[u]||C.createElement("div")});for(var L,M=Object.keys(B).map(function(a){return B[a]}),O=M.sort(function(a,b){return a.action-b.action||a.index-b.index}),P=k.slice(),u=0;L=O[u];u++){if(L.action==y&&(h(k[L.index].nodes,k[L.index]),P.splice(L.index,1)),L.action==z){var Q=C.createElement("div");Q.key=i[L.index].attrs.key,a.insertBefore(Q,a.childNodes[L.index]||null),P.splice(L.index,0,{attrs:{key:i[L.index].attrs.key},nodes:[Q]})}L.action==A&&(a.childNodes[L.index]!==L.element&&null!==L.element&&a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.from])}for(var u=0;u<D.length;u++){var L=D[u];a.insertBefore(L.element,a.childNodes[L.index]||null),P[L.index]=k[L.index]}k=P,k.nodes=[];for(var R,u=0;R=a.childNodes[u];u++)k.nodes.push(R)}for(var u=0,S=0;u<i.length;u++){var T=f(a,b,k,m,i[u],k[S],l,m+x||x,n,o,p);T!==c&&(T.nodes.intact||(w=!1),x+=T.$trusted?(T.match(/<[^\/]|\>\s*[^<]/g)||[]).length:K.call(T)==H?T.length:1,k[S++]=T)}if(!w){for(var u=0;u<i.length;u++)null!=k[u]&&v.push.apply(v,k[u].nodes);for(var U,u=0;U=k.nodes[u];u++)null!=U.parentNode&&v.indexOf(U)<0&&h([U],[k[u]]);i.length<k.length&&(k.length=i.length),k.nodes=v}}else if(null!=i&&r==G){i.attrs||(i.attrs={}),k.attrs||(k.attrs={});{var V=Object.keys(i.attrs);V.length>("key"in i.attrs?1:0)}if((i.tag!=k.tag||V.join()!=Object.keys(k.attrs).join()||i.attrs.id!=k.attrs.id)&&(k.nodes.length&&h(k.nodes),k.configContext&&typeof k.configContext.onunload==J&&k.configContext.onunload()),K.call(i.tag)!=I)return;var U,W=0===k.nodes.length;if(i.attrs.xmlns?o=i.attrs.xmlns:"svg"===i.tag?o="http://www.w3.org/2000/svg":"math"===i.tag&&(o="http://www.w3.org/1998/Math/MathML"),W?(U=i.attrs.is?o===c?C.createElement(i.tag,i.attrs.is):C.createElementNS(o,i.tag,i.attrs.is):o===c?C.createElement(i.tag):C.createElementNS(o,i.tag),k={tag:i.tag,attrs:V.length?g(U,i.tag,i.attrs,{},o):{},children:null!=i.children&&i.children.length>0?f(U,i.tag,c,c,i.children,k.children,!0,0,i.attrs.contenteditable?U:n,o,p):i.children,nodes:[U]},k.children&&!k.children.nodes&&(k.children.nodes=[]),"select"==i.tag&&i.attrs.value&&g(U,i.tag,{value:i.attrs.value},{},o),a.insertBefore(U,a.childNodes[m]||null)):(U=k.nodes[0],V.length&&g(U,i.tag,i.attrs,k.attrs,o),k.children=f(U,i.tag,c,c,i.children,k.children,!1,0,i.attrs.contenteditable?U:n,o,p),k.nodes.intact=!0,l===!0&&null!=U&&a.insertBefore(U,a.childNodes[m]||null)),typeof i.attrs.config==J){var X=k.configContext=k.configContext||{},Y=function(a,b){return function(){return a.attrs.config.apply(a,b)}};p.push(Y(i,[U,!W,X,k]))}}else if(typeof r!=J){var v;0===k.nodes.length?(i.$trusted?v=j(a,m,i):(v=[C.createTextNode(i)],a.nodeName.match(N)||a.insertBefore(v[0],a.childNodes[m]||null)),k="string number boolean".indexOf(typeof i)>-1?new i.constructor(i):i,k.nodes=v):k.valueOf()!==i.valueOf()||l===!0?(v=k.nodes,n&&n===C.activeElement||(i.$trusted?(h(v,k),v=j(a,m,i)):"textarea"===b?a.value=i:n?n.innerHTML=i:((1==v[0].nodeType||v.length>1)&&(h(k.nodes,k),v=[C.createTextNode(i)]),a.insertBefore(v[0],a.childNodes[m]||null),v[0].nodeValue=i)),k=new i.constructor(i),k.nodes=v):k.nodes.intact=!0}return k}function g(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!=g&&(a.value=g);else{d[f]=g;try{if("config"===f)continue;if(typeof g==J&&0==f.indexOf("on"))a[f]=k(g,a);else if("style"===f&&null!=g&&K.call(g)==G){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!=f&&"style"!=f&&"form"!=f&&"type"!=f?a[f]!=g&&(a[f]=g):a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function h(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&i(b[c])}0!=a.length&&(a.length=0)}function i(a){if(a.configContext&&typeof a.configContext.onunload==J&&a.configContext.onunload(),a.children)if(K.call(a.children)==H)for(var b=0;b<a.children.length;b++)i(a.children[b]);else a.children.tag&&i(a.children)}function j(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=C.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function k(a,b){return function(c){c=c||event,e.redraw.strategy("diff"),e.startComputation();try{return a.call(b,c)}finally{e.endComputation()}}}function l(a){var b=Q.indexOf(a);return 0>b?Q.push(a)-1:b}function m(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function n(){for(var a=e.redraw.strategy(),b=0;b<T.length;b++)V[b]&&"none"!=a&&e.render(T[b],U[b].view(V[b]),"all"==a);Y&&(Y(),Y=null),W=null,X=new Date,e.redraw.strategy("diff")}function o(a){return a.slice(bb[e.route.mode].length)}function p(a,b,c){_={};var d=c.indexOf("?");-1!==d&&(_=t(c.substr(d+1,c.length)),c=c.substr(0,d));for(var f in b){if(f==c)return e.module(a,b[f]),!0;var g=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(g.test(c))return c.replace(g,function(){for(var c=f.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0;g<c.length;g++)_[c[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);e.module(a,b[f])}),!0}}function q(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!=a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this,c="pathname"==e.route.mode&&b.search?t(b.search.slice(1)):{};e.route(b[e.route.mode].slice(bb[e.route.mode].length),c)}}function r(){"hash"!=e.route.mode&&D.hash?D.hash=D.hash:b.scrollTo(0,0)}function s(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d];c.push(null!=f&&K.call(f)==G?s(f,e):encodeURIComponent(e)+"="+encodeURIComponent(f))}return c.join("&")}function t(a){for(var b=a.split("&"),c={},d=0;d<b.length;d++){var e=b[d].split("=");c[u(e[0])]=e[1]?u(e[1]):""}return c}function u(a){return decodeURIComponent(a.replace(/\+/g," "))}function v(a){var b=l(a);h(a.childNodes,R[b]),R[b]=c}function w(a){var b=e.prop();return a.then(b),b.then=function(b,c){return w(a.then(b,c))},b}function x(a,b){function c(a){l=a||j,n.map(function(a){l==i&&a.resolve(m)||a.reject(m)})}function d(a,b,c,d){if((null!=m&&K.call(m)==G||typeof m==J)&&typeof a==J)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){e.deferred.onerror(g),m=g,c()}else d()}function f(){var j;try{j=m&&m.then}catch(n){return e.deferred.onerror(n),m=n,l=h,f()}d(j,function(){l=g,f()},function(){l=h,f()},function(){try{l==g&&typeof a==J?m=a(m):l==h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return e.deferred.onerror(f),m=f,c()}m==k?(m=TypeError(),c()):d(j,function(){c(i)},c,function(){c(l==g&&i)})})}var g=1,h=2,i=3,j=4,k=this,l=0,m=0,n=[];k.promise={},k.resolve=function(a){return l||(m=a,l=g,f()),this},k.reject=function(a){return l||(m=a,l=h,f()),this},k.promise.then=function(a,b){var c=new x(a,b);return l==i?c.resolve(m):l==j?c.reject(m):n.push(c),c.promise}}function y(a){return a}function z(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var d=new b.XMLHttpRequest;if(d.open(a.method,a.url,!0,a.user,a.password),d.onreadystatechange=function(){4===d.readyState&&(d.status>=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize==JSON.stringify&&a.data&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize==JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config==J){var e=a.config(d,a);null!=e&&(d=e)}var f="GET"!=a.method&&a.data?a.data:"";if(f&&K.call(f)!=I&&f.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send(f),d}var g="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),h=C.createElement("script");b[g]=function(d){C.body.removeChild(h),a.onload({type:"load",target:{responseText:d}}),b[g]=c},h.onerror=function(){return C.body.removeChild(h),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[g]=c,!1},h.onload=function(){return!1},h.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+g+"&"+s(a.data||{}),C.body.appendChild(h)}function A(a,b,c){if("GET"==a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=s(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function B(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;d<c.length;d++){var e=c[d].slice(1);a=a.replace(c[d],b[e]),delete b[e]}return a}var C,D,E,F,G="[object Object]",H="[object Array]",I="[object String]",J="function",K={}.toString,L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;d(b);var O,P={appendChild:function(a){O===c&&(O=C.createElement("html")),C.documentElement&&C.documentElement!==a?C.replaceChild(a,C.documentElement):C.appendChild(a),this.childNodes=C.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},Q=[],R={};e.render=function(a,b,d){var e=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=l(a),i=a==C,j=i||a==C.documentElement?P:a;i&&"html"!=b.tag&&(b={tag:"html",attrs:{},children:b}),R[g]===c&&h(j.childNodes),d===!0&&v(a),R[g]=f(j,null,c,c,b,R[g],!1,0,null,c,e);for(var k=0;k<e.length;k++)e[k]()},e.trust=function(a){return a=new String(a),a.$trusted=!0,a},e.prop=function(a){return(null!=a&&K.call(a)==G||typeof a==J)&&typeof a.then==J?w(a):m(a)};var S,T=[],U=[],V=[],W=null,X=0,Y=null,Z=16;e.module=function(a,b){var c=T.indexOf(a);0>c&&(c=T.length);var d=!1;if(V[c]&&typeof V[c].onunload==J){var f={preventDefault:function(){d=!0}};V[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),T[c]=a;var g=S=b,h=new b.controller;return g==S&&(V[c]=h,U[c]=b),e.endComputation(),V[c]}},e.redraw=function(a){W&&a!==!0?(new Date-X>Z||E==b.requestAnimationFrame)&&(W>0&&F(W),W=E(n,Z)):(n(),W=E(function(){W=null},Z))},e.redraw.strategy=e.prop();var $=0;e.startComputation=function(){$++},e.endComputation=function(){$=Math.max($-1,0),0==$&&e.redraw()},e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var _,ab,bb={pathname:"",hash:"#",search:"?"},cb=function(){};return e.route=function(){if(0===arguments.length)return ab;if(3===arguments.length&&K.call(arguments[1])==I){var a=arguments[0],c=arguments[1],d=arguments[2];cb=function(b){var f=ab=o(b);p(a,d,f)||e.route(c,!0)};var f="hash"==e.route.mode?"onhashchange":"onpopstate";b[f]=function(){ab!=o(D[e.route.mode])&&cb(D[e.route.mode])},Y=r,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?D.pathname:"")+bb[e.route.mode]+this.attrs.href,g.removeEventListener("click",q),g.addEventListener("click",q)}else if(K.call(arguments[0])==I){ab=arguments[0];var h=arguments[1]||{},i=ab.indexOf("?"),j=i>-1?t(ab.slice(i+1)):{};for(var k in h)j[k]=h[k];var l=s(j),m=i>-1?ab.slice(0,i):ab;l&&(ab=m+(-1===m.indexOf("?")?"?":"&")+l);var n=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(Y=function(){b.history[n?"replaceState":"pushState"](null,C.title,bb[e.route.mode]+ab),r()},cb(bb[e.route.mode]+ab)):D[e.route.mode]=ab}},e.route.param=function(a){if(!_)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return _[a]},e.route.mode="search",e.deferred=function(){var a=new x;return a.promise=w(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"==K.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0==--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h<a.length;h++)a[h].then(b(h,!0),b(h,!1));else d.resolve([]);return d.promise},e.request=function(a){a.background!==!0&&e.startComputation();var b=e.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?y:a.serialize||JSON.stringify,f=a.deserialize=c?y:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&f===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"==c.type?a.unwrapSuccess:a.unwrapError)||y,h=d(f(g(c.target,a)));if("load"==c.type)if(K.call(h)==H&&a.type)for(var i=0;i<h.length;i++)h[i]=new a.type(h[i]);else a.type&&(h=new a.type(h));b["load"==c.type?"resolve":"reject"](h)}catch(c){e.deferred.onerror(c),b.reject(c)}a.background!==!0&&e.endComputation()},z(a),b.promise(a.initialValue),b.promise},e.deps=function(a){return d(b=a||b),b},e.deps.factory=a,e}("undefined"!=typeof window?window:{});"undefined"!=typeof module&&null!==module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m}); | ||
var m=function a(b,c){function d(a){C=a.document,D=a.location,F=a.cancelAnimationFrame||a.clearTimeout,E=a.requestAnimationFrame||a.setTimeout}function e(){var a,b=[].slice.call(arguments),c=!(null==b[1]||K.call(b[1])!==G||"tag"in b[1]||"subtree"in b[1]),d=c?b[1]:{},e="class"in d?"class":"className",f={tag:"div",attrs:{}},g=[];if(K.call(b[0])!=I)throw new Error("selector in m(selector, attrs, children) should be a string");for(;a=L.exec(b[0]);)if(""===a[1]&&a[2])f.tag=a[2];else if("#"===a[1])f.attrs.id=a[2];else if("."===a[1])g.push(a[2]);else if("["===a[3][0]){var h=M.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" "));var i=c?b[2]:b[1];f.children=K.call(i)===H?i:b.slice(c?2:1);for(var j in d)f.attrs[j]=j===e?(f.attrs[j]||"")+" "+d[j]:d[j];return f}function f(a,b,d,e,i,k,l,m,n,o,p){if((null==i||null==i.toString())&&(i=""),"retain"===i.subtree)return k;var q=K.call(k),r=K.call(i);if(null==k||q!==r){if(null!=k)if(d&&d.nodes){var s=m-e,t=s+(r===H?i:k.nodes).length;h(d.nodes.slice(s,t),d.slice(s,t))}else k.nodes&&h(k.nodes,k);k=new i.constructor,k.tag&&(k={}),k.nodes=[]}if(r===H){for(var u=0,v=i.length;v>u;u++)K.call(i[u])===H&&(i=i.concat.apply([],i),u--);for(var w=[],x=k.length===i.length,y=0,z=1,A=2,B=3,D={},E=[],F=!1,u=0,v=k.length;v>u;u++)k[u]&&k[u].attrs&&null!=k[u].attrs.key&&(F=!0,D[k[u].attrs.key]={action:z,index:u});if(F){i.indexOf(null)>-1&&(i=i.filter(function(a){return null!=a}));for(var u=0,v=i.length;v>u;u++)if(i[u]&&i[u].attrs)if(null!=i[u].attrs.key){var L=i[u].attrs.key;D[L]=D[L]?{action:B,index:u,from:D[L].index,element:a.childNodes[D[L].index]||C.createElement("div")}:{action:A,index:u}}else E.push({index:u,element:a.childNodes[u]||C.createElement("div")});for(var M,O=Object.keys(D).map(function(a){return D[a]}),P=O.sort(function(a,b){return a.action-b.action||a.index-b.index}),Q=k.slice(),u=0;M=P[u];u++){if(M.action===z&&(h(k[M.index].nodes,k[M.index]),Q.splice(M.index,1)),M.action===A){var R=C.createElement("div");R.key=i[M.index].attrs.key,a.insertBefore(R,a.childNodes[M.index]||null),Q.splice(M.index,0,{attrs:{key:i[M.index].attrs.key},nodes:[R]})}M.action===B&&(a.childNodes[M.index]!==M.element&&null!==M.element&&a.insertBefore(M.element,a.childNodes[M.index]||null),Q[M.index]=k[M.from])}for(var u=0,v=E.length;v>u;u++){var M=E[u];a.insertBefore(M.element,a.childNodes[M.index]||null),Q[M.index]=k[M.index]}k=Q,k.nodes=[];for(var S,u=0;S=a.childNodes[u];u++)k.nodes.push(S)}for(var u=0,T=0,v=i.length;v>u;u++){var U=f(a,b,k,m,i[u],k[T],l,m+y||y,n,o,p);U!==c&&(U.nodes.intact||(x=!1),y+=U.$trusted?(U.match(/<[^\/]|\>\s*[^<]/g)||[]).length:K.call(U)===H?U.length:1,k[T++]=U)}if(!x){for(var u=0,v=i.length;v>u;u++)null!=k[u]&&w.push.apply(w,k[u].nodes);for(var V,u=0;V=k.nodes[u];u++)null!=V.parentNode&&w.indexOf(V)<0&&h([V],[k[u]]);i.length<k.length&&(k.length=i.length),k.nodes=w}}else if(null!=i&&r===G){i.attrs||(i.attrs={}),k.attrs||(k.attrs={});{var W=Object.keys(i.attrs);W.length>("key"in i.attrs?1:0)}if((i.tag!=k.tag||W.join()!=Object.keys(k.attrs).join()||i.attrs.id!=k.attrs.id)&&(k.nodes.length&&h(k.nodes),k.configContext&&typeof k.configContext.onunload===J&&k.configContext.onunload()),K.call(i.tag)!=I)return;var V,X=0===k.nodes.length;if(i.attrs.xmlns?o=i.attrs.xmlns:"svg"===i.tag?o="http://www.w3.org/2000/svg":"math"===i.tag&&(o="http://www.w3.org/1998/Math/MathML"),X?(V=i.attrs.is?o===c?C.createElement(i.tag,i.attrs.is):C.createElementNS(o,i.tag,i.attrs.is):o===c?C.createElement(i.tag):C.createElementNS(o,i.tag),k={tag:i.tag,attrs:W.length?g(V,i.tag,i.attrs,{},o):{},children:null!=i.children&&i.children.length>0?f(V,i.tag,c,c,i.children,k.children,!0,0,i.attrs.contenteditable?V:n,o,p):i.children,nodes:[V]},k.children&&!k.children.nodes&&(k.children.nodes=[]),"select"===i.tag&&i.attrs.value&&g(V,i.tag,{value:i.attrs.value},{},o),a.insertBefore(V,a.childNodes[m]||null)):(V=k.nodes[0],W.length&&g(V,i.tag,i.attrs,k.attrs,o),k.children=f(V,i.tag,c,c,i.children,k.children,!1,0,i.attrs.contenteditable?V:n,o,p),k.nodes.intact=!0,l===!0&&null!=V&&a.insertBefore(V,a.childNodes[m]||null)),typeof i.attrs.config===J){var Y=k.configContext=k.configContext||{},Z=function(a,b){return function(){return a.attrs.config.apply(a,b)}};p.push(Z(i,[V,!X,Y,k]))}}else if(typeof r!=J){var w;0===k.nodes.length?(i.$trusted?w=j(a,m,i):(w=[C.createTextNode(i)],a.nodeName.match(N)||a.insertBefore(w[0],a.childNodes[m]||null)),k="string number boolean".indexOf(typeof i)>-1?new i.constructor(i):i,k.nodes=w):k.valueOf()!==i.valueOf()||l===!0?(w=k.nodes,n&&n===C.activeElement||(i.$trusted?(h(w,k),w=j(a,m,i)):"textarea"===b?a.value=i:n?n.innerHTML=i:((1===w[0].nodeType||w.length>1)&&(h(k.nodes,k),w=[C.createTextNode(i)]),a.insertBefore(w[0],a.childNodes[m]||null),w[0].nodeValue=i)),k=new i.constructor(i),k.nodes=w):k.nodes.intact=!0}return k}function g(a,b,c,d,e){for(var f in c){var g=c[f],h=d[f];if(f in d&&h===g)"value"===f&&"input"===b&&a.value!=g&&(a.value=g);else{d[f]=g;try{if("config"===f)continue;if(typeof g===J&&0===f.indexOf("on"))a[f]=k(g,a);else if("style"===f&&null!=g&&K.call(g)===G){for(var i in g)(null==h||h[i]!==g[i])&&(a.style[i]=g[i]);for(var i in h)i in g||(a.style[i]="")}else null!=e?"href"===f?a.setAttributeNS("http://www.w3.org/1999/xlink","href",g):"className"===f?a.setAttribute("class",g):a.setAttribute(f,g):f in a&&"list"!==f&&"style"!==f&&"form"!==f&&"type"!==f?("input"!=f||a[f]!==g)&&(a[f]=g):a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}function h(a,b){for(var c=a.length-1;c>-1;c--)if(a[c]&&a[c].parentNode){try{a[c].parentNode.removeChild(a[c])}catch(d){}b=[].concat(b),b[c]&&i(b[c])}0!=a.length&&(a.length=0)}function i(a){if(a.configContext&&typeof a.configContext.onunload===J&&a.configContext.onunload(),a.children)if(K.call(a.children)===H)for(var b,c=0;b=a.children[c];c++)i(b);else a.children.tag&&i(a.children)}function j(a,b,c){var d=a.childNodes[b];if(d){var e=1!=d.nodeType,f=C.createElement("span");e?(a.insertBefore(f,d||null),f.insertAdjacentHTML("beforebegin",c),a.removeChild(f)):d.insertAdjacentHTML("beforebegin",c)}else a.insertAdjacentHTML("beforeend",c);for(var g=[];a.childNodes[b]!==d;)g.push(a.childNodes[b]),b++;return g}function k(a,b){return function(c){c=c||event,e.redraw.strategy("diff"),e.startComputation();try{return a.call(b,c)}finally{_()}}}function l(a){var b=Q.indexOf(a);return 0>b?Q.push(a)-1:b}function m(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function n(){for(var a,b="all"===e.redraw.strategy(),c=0;a=T[c];c++)V[c]&&e.render(a,U[c].view(V[c]),b);Y&&(Y(),Y=null),W=null,X=new Date,e.redraw.strategy("diff")}function o(a){return a.slice(cb[e.route.mode].length)}function p(a,b,c){ab={};var d=c.indexOf("?");-1!==d&&(ab=t(c.substr(d+1,c.length)),c=c.substr(0,d));for(var f in b){if(f===c)return e.module(a,b[f]),!0;var g=new RegExp("^"+f.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(g.test(c))return c.replace(g,function(){for(var c=f.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),g=0,h=c.length;h>g;g++)ab[c[g].replace(/:|\./g,"")]=decodeURIComponent(d[g]);e.module(a,b[f])}),!0}}function q(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!==a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this,c="pathname"===e.route.mode&&b.search?t(b.search.slice(1)):{};e.route(b[e.route.mode].slice(cb[e.route.mode].length),c)}}function r(){"hash"!=e.route.mode&&D.hash?D.hash=D.hash:b.scrollTo(0,0)}function s(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d];c.push(null!=f&&K.call(f)===G?s(f,e):encodeURIComponent(e)+"="+encodeURIComponent(f))}return c.join("&")}function t(a){for(var b=a.split("&"),c={},d=0,e=b.length;e>d;d++){var f=b[d].split("=");c[u(f[0])]=f[1]?u(f[1]):""}return c}function u(a){return decodeURIComponent(a.replace(/\+/g," "))}function v(a){var b=l(a);h(a.childNodes,R[b]),R[b]=c}function w(a){var b=e.prop();return a.then(b),b.then=function(b,c){return w(a.then(b,c))},b}function x(a,b){function c(a){l=a||j,n.map(function(a){l===i&&a.resolve(m)||a.reject(m)})}function d(a,b,c,d){if((null!=m&&K.call(m)===G||typeof m===J)&&typeof a===J)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){e.deferred.onerror(g),m=g,c()}else d()}function f(){var j;try{j=m&&m.then}catch(n){return e.deferred.onerror(n),m=n,l=h,f()}d(j,function(){l=g,f()},function(){l=h,f()},function(){try{l===g&&typeof a===J?m=a(m):l===h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return e.deferred.onerror(f),m=f,c()}m===k?(m=TypeError(),c()):d(j,function(){c(i)},c,function(){c(l===g&&i)})})}var g=1,h=2,i=3,j=4,k=this,l=0,m=0,n=[];k.promise={},k.resolve=function(a){return l||(m=a,l=g,f()),this},k.reject=function(a){return l||(m=a,l=h,f()),this},k.promise.then=function(a,b){var c=new x(a,b);return l===i?c.resolve(m):l===j?c.reject(m):n.push(c),c.promise}}function y(a){return a}function z(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){var d=new b.XMLHttpRequest;if(d.open(a.method,a.url,!0,a.user,a.password),d.onreadystatechange=function(){4===d.readyState&&(d.status>=200&&d.status<300?a.onload({type:"load",target:d}):a.onerror({type:"error",target:d}))},a.serialize===JSON.stringify&&a.data&&"GET"!==a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize===JSON.parse&&d.setRequestHeader("Accept","application/json, text/*"),typeof a.config===J){var e=a.config(d,a);null!=e&&(d=e)}var f="GET"!==a.method&&a.data?a.data:"";if(f&&K.call(f)!=I&&f.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send(f),d}var g="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),h=C.createElement("script");b[g]=function(d){C.body.removeChild(h),a.onload({type:"load",target:{responseText:d}}),b[g]=c},h.onerror=function(){return C.body.removeChild(h),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[g]=c,!1},h.onload=function(){return!1},h.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+g+"&"+s(a.data||{}),C.body.appendChild(h)}function A(a,b,c){if("GET"===a.method&&"jsonp"!=a.dataType){var d=a.url.indexOf("?")<0?"?":"&",e=s(b);a.url=a.url+(e?d+e:"")}else a.data=c(b);return a}function B(a,b){var c=a.match(/:[a-z]\w+/gi);if(c&&b)for(var d=0;d<c.length;d++){var e=c[d].slice(1);a=a.replace(c[d],b[e]),delete b[e]}return a}var C,D,E,F,G="[object Object]",H="[object Array]",I="[object String]",J="function",K={}.toString,L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;d(b);var O,P={appendChild:function(a){O===c&&(O=C.createElement("html")),C.documentElement&&C.documentElement!==a?C.replaceChild(a,C.documentElement):C.appendChild(a),this.childNodes=C.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},Q=[],R={};e.render=function(a,b,d){var e=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=l(a),i=a===C,j=i||a===C.documentElement?P:a;i&&"html"!=b.tag&&(b={tag:"html",attrs:{},children:b}),R[g]===c&&h(j.childNodes),d===!0&&v(a),R[g]=f(j,null,c,c,b,R[g],!1,0,null,c,e);for(var k=0,m=e.length;m>k;k++)e[k]()},e.trust=function(a){return a=new String(a),a.$trusted=!0,a},e.prop=function(a){return(null!=a&&K.call(a)===G||typeof a===J)&&typeof a.then===J?w(a):m(a)};var S,T=[],U=[],V=[],W=null,X=0,Y=null,Z=16;e.module=function(a,b){var c=T.indexOf(a);0>c&&(c=T.length);var d=!1;if(V[c]&&typeof V[c].onunload===J){var f={preventDefault:function(){d=!0}};V[c].onunload(f)}if(!d){e.redraw.strategy("all"),e.startComputation(),T[c]=a;var g=S=b,h=new b.controller;return g===S&&(V[c]=h,U[c]=b),_(),V[c]}},e.redraw=function(a){W&&a!==!0?(new Date-X>Z||E===b.requestAnimationFrame)&&(W>0&&F(W),W=E(n,Z)):(n(),W=E(function(){W=null},Z))},e.redraw.strategy=e.prop();var $=0;e.startComputation=function(){$++},e.endComputation=function(){$=Math.max($-1,0),0===$&&e.redraw()};var _=function(){"none"==e.redraw.strategy()?($--,e.redraw.strategy("diff")):e.endComputation()};e.withAttr=function(a,b){return function(c){c=c||event;var d=c.currentTarget||this;b(a in d?d[a]:d.getAttribute(a))}};var ab,bb,cb={pathname:"",hash:"#",search:"?"},db=function(){};return e.route=function(){if(0===arguments.length)return bb;if(3===arguments.length&&K.call(arguments[1])===I){var a=arguments[0],c=arguments[1],d=arguments[2];db=function(b){var f=bb=o(b);p(a,d,f)||e.route(c,!0)};var f="hash"===e.route.mode?"onhashchange":"onpopstate";b[f]=function(){bb!=o(D[e.route.mode])&&db(D[e.route.mode])},Y=r,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==e.route.mode?D.pathname:"")+cb[e.route.mode]+this.attrs.href,g.removeEventListener("click",q),g.addEventListener("click",q)}else if(K.call(arguments[0])===I){bb=arguments[0];var h=arguments[1]||{},i=bb.indexOf("?"),j=i>-1?t(bb.slice(i+1)):{};for(var k in h)j[k]=h[k];var l=s(j),m=i>-1?bb.slice(0,i):bb;l&&(bb=m+(-1===m.indexOf("?")?"?":"&")+l);var n=(3===arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(Y=function(){b.history[n?"replaceState":"pushState"](null,C.title,cb[e.route.mode]+bb),r()},db(cb[e.route.mode]+bb)):D[e.route.mode]=bb}},e.route.param=function(a){if(!ab)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return ab[a]},e.route.mode="search",e.deferred=function(){var a=new x;return a.promise=w(a.promise),a},e.deferred.onerror=function(a){if("[object Error]"===K.call(a)&&!a.constructor.toString().match(/ Error/))throw a},e.sync=function(a){function b(a,b){return function(e){return g[a]=e,b||(c="reject"),0===--f&&(d.promise(g),d[c](g)),e}}var c="resolve",d=e.deferred(),f=a.length,g=new Array(f);if(a.length>0)for(var h=0;h<a.length;h++)a[h].then(b(h,!0),b(h,!1));else d.resolve([]);return d.promise},e.request=function(a){a.background!==!0&&e.startComputation();var b=e.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?y:a.serialize||JSON.stringify,f=a.deserialize=c?y:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&f===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"===c.type?a.unwrapSuccess:a.unwrapError)||y,h=d(f(g(c.target,a)));if("load"===c.type)if(K.call(h)===H&&a.type)for(var i=0;i<h.length;i++)h[i]=new a.type(h[i]);else a.type&&(h=new a.type(h));b["load"===c.type?"resolve":"reject"](h)}catch(c){e.deferred.onerror(c),b.reject(c)}a.background!==!0&&e.endComputation()},z(a),b.promise(a.initialValue),b.promise},e.deps=function(a){return d(b=a||b),b},e.deps.factory=a,e}("undefined"!=typeof window?window:{});"undefined"!=typeof module&&null!==module&&module.exports?module.exports=m:"function"==typeof define&&define.amd&&define(function(){return m}); | ||
//# sourceMappingURL=mithril.min.js.map |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mvc", "framework"], | ||
"version": "0.1.26", | ||
"version": "0.1.27", | ||
"author": "Leo Horie <leohorie@hotmail.com>", | ||
@@ -8,0 +8,0 @@ "repository": {"type": "git", "url": "https://github.com/lhorie/mithril"}, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
55368
996