Comparing version 0.1.20 to 0.1.21
281
mithril.js
Mithril = m = new function app(window, undefined) { | ||
var type = {}.toString | ||
var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/ | ||
var voidElements = /AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR/ | ||
function m() { | ||
var args = arguments | ||
var hasAttrs = args[1] !== undefined && type.call(args[1]) == "[object Object]" && !("tag" in args[1]) && !("subtree" in args[1]) | ||
var hasAttrs = args[1] != null && type.call(args[1]) == "[object Object]" && !("tag" in args[1]) && !("subtree" in args[1]) | ||
var attrs = hasAttrs ? args[1] : {} | ||
@@ -22,5 +23,5 @@ var classAttrName = "class" in attrs ? "class" : "className" | ||
if (classes.length > 0) cell.attrs[classAttrName] = classes.join(" ") | ||
cell.children = hasAttrs ? args[2] : args[1] | ||
for (var attrName in attrs) { | ||
@@ -34,2 +35,12 @@ if (attrName == classAttrName) cell.attrs[attrName] = (cell.attrs[attrName] || "") + " " + attrs[attrName] | ||
//`build` is a recursive function that manages creation/diffing/removal of DOM elements based on comparison between `data` and `cached` | ||
//the diff algorithm can be summarized as this: | ||
//1 - compare `data` and `cached` | ||
//2 - if they are different, copy `data` to `cached` and update the DOM based on what the difference is | ||
//3 - recursively apply this algorithm for every array and for the children of every virtual element | ||
//the `cached` data structure is essentially the same as the previous redraw's `data` data structure, with a few additions: | ||
//- `cached` always has a property called `nodes`, which is a list of DOM elements that correspond to the data represented by the respective virtual element | ||
//- in order to support attaching `nodes` as a property of `cached`, `cached` is *always* a non-primitive object, i.e. if the data was a string, then cached is a String instance. If data was `null` or `undefined`, cached is `new String("")` | ||
//- `cached also has a `configContext` property, which is the state storage object exposed by config(element, isInitialized, context) | ||
//- when `cached` is an Object, it represents a virtual element; when it's an Array, it represents a list of elements; when it's a String, Number or Boolean, it represents a text node | ||
@@ -45,12 +56,12 @@ //`parentElement` is a DOM element used for W3C DOM API calls | ||
//`configs` is a list of config functions to run after the topmost `build` call finishes running | ||
//there's logic that relies on the assumption that null and undefined data are equivalent to empty strings | ||
//- this prevents lifecycle surprises from procedural helpers that mix implicit and explicit return statements | ||
//- it simplifies diffing code | ||
if (data === undefined || data === null) data = "" | ||
if (data == null) data = "" | ||
if (data.subtree === "retain") return cached | ||
var cachedType = type.call(cached), dataType = type.call(data) | ||
if (cached === undefined || cached === null || cachedType != dataType) { | ||
if (cached !== null && cached !== undefined) { | ||
if (cached == null || cachedType != dataType) { | ||
if (cached != null) { | ||
if (parentCache && parentCache.nodes) { | ||
@@ -70,4 +81,4 @@ var offset = index - parentIndex | ||
var nodes = [], intact = cached.length === data.length, subArrayCount = 0 | ||
//key algorithm: sort elements without recreating them if keys are present | ||
//keys algorithm: sort elements without recreating them if keys are present | ||
//1) create a map of all existing keys, and mark all for deletion | ||
@@ -81,3 +92,3 @@ //2) add new keys to map and mark them for addition | ||
for (var i = 0; i < cached.length; i++) { | ||
if (cached[i] && cached[i].attrs && cached[i].attrs.key !== undefined) { | ||
if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) { | ||
shouldMaintainIdentities = true | ||
@@ -90,3 +101,3 @@ existing[cached[i].attrs.key] = {action: DELETION, index: i} | ||
if (data[i] && data[i].attrs) { | ||
if (data[i].attrs.key !== undefined) { | ||
if (data[i].attrs.key != null) { | ||
var key = data[i].attrs.key | ||
@@ -102,3 +113,3 @@ if (!existing[key]) existing[key] = {action: INSERTION, index: i} | ||
var newCached = cached.slice() | ||
for (var i = 0, change; change = changes[i]; i++) { | ||
@@ -115,3 +126,3 @@ if (change.action == DELETION) { | ||
} | ||
if (change.action == MOVE) { | ||
@@ -134,4 +145,5 @@ if (parentElement.childNodes[change.index] !== change.element && change.element !== null) { | ||
//end key algorithm | ||
for (var i = 0, cacheCount = 0; i < data.length; i++) { | ||
//diff each item in the array | ||
var item = build(parentElement, parentTag, cached, index, data[i], cached[cacheCount], shouldReattach, index + subArrayCount || subArrayCount, editable, namespace, configs) | ||
@@ -145,10 +157,16 @@ if (item === undefined) continue | ||
if (!intact) { | ||
//diff the array itself | ||
//update the list of DOM nodes by collecting the nodes from each item | ||
for (var i = 0; i < data.length; i++) { | ||
if (cached[i] !== undefined) nodes = nodes.concat(cached[i].nodes) | ||
if (cached[i] != null) nodes = nodes.concat(cached[i].nodes) | ||
} | ||
//remove items from the end of the array if the new array is shorter than the old one | ||
//if errors ever happen here, the issue is most likely a bug in the construction of the `cached` data structure somewhere earlier in the program | ||
for (var i = 0, node; node = cached.nodes[i]; i++) { | ||
if (node.parentNode !== null && nodes.indexOf(node) < 0) node.parentNode.removeChild(node) | ||
if (node.parentNode != null && nodes.indexOf(node) < 0) clear([node], [cached[i]]) | ||
} | ||
//add items to the end if the new array is longer than the old one | ||
for (var i = cached.nodes.length, node; node = nodes[i]; i++) { | ||
if (node.parentNode === null) parentElement.appendChild(node) | ||
if (node.parentNode == null) parentElement.appendChild(node) | ||
} | ||
@@ -158,5 +176,4 @@ if (data.length < cached.length) cached.length = data.length | ||
} | ||
} | ||
else if (data !== undefined && dataType == "[object Object]") { | ||
else if (data != null && dataType == "[object Object]") { | ||
//if an element is different enough from the one in cache, recreate it | ||
@@ -178,3 +195,3 @@ if (data.tag != cached.tag || Object.keys(data.attrs).join() != Object.keys(cached.attrs).join() || data.attrs.id != cached.attrs.id) { | ||
//process children before attrs so that select.value works correctly | ||
children: data.children !== undefined ? build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : [], | ||
children: build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs), | ||
attrs: setAttributes(node, data.tag, data.attrs, {}, namespace), | ||
@@ -188,5 +205,5 @@ nodes: [node] | ||
setAttributes(node, data.tag, data.attrs, cached.attrs, namespace) | ||
cached.children = data.children !== undefined ? build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs) : [] | ||
cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs) | ||
cached.nodes.intact = true | ||
if (shouldReattach === true && node !== null) parentElement.insertBefore(node, parentElement.childNodes[index] || null) | ||
if (shouldReattach === true && node != null) parentElement.insertBefore(node, parentElement.childNodes[index] || null) | ||
} | ||
@@ -207,3 +224,3 @@ //schedule configs to be called. They are called after `build` finishes running | ||
nodes = [window.document.createTextNode(data)] | ||
parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null) | ||
if (!parentElement.nodeName.match(voidElements)) parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null) | ||
} | ||
@@ -222,2 +239,3 @@ cached = "string number boolean".indexOf(typeof data) > -1 ? new data.constructor(data) : data | ||
//corner case: replacing the nodeValue of a text node that is a child of a textarea/contenteditable doesn't work | ||
//we need to update the value property of the parent textarea or the innerHTML of the contenteditable element instead | ||
if (parentTag === "textarea") parentElement.value = data | ||
@@ -256,3 +274,3 @@ else if (editable) editable.innerHTML = data | ||
for (var rule in dataAttr) { | ||
if (cachedAttr === undefined || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] | ||
if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule] | ||
} | ||
@@ -263,3 +281,3 @@ for (var rule in cachedAttr) { | ||
} | ||
else if (namespace !== undefined) { | ||
else if (namespace != null) { | ||
if (attrName === "href") node.setAttributeNS("http://www.w3.org/1999/xlink", "href", dataAttr) | ||
@@ -381,3 +399,3 @@ else if (attrName === "className") node.setAttribute("class", dataAttr) | ||
m.prop = function(store) { | ||
function _prop(store) { | ||
var prop = function() { | ||
@@ -387,8 +405,22 @@ if (arguments.length) store = arguments[0] | ||
} | ||
prop.toJSON = function() { | ||
return store | ||
} | ||
return prop | ||
} | ||
m.prop = function (store) { | ||
if ((typeof store === 'object' || typeof store === 'function') && | ||
typeof store.then === 'function') { | ||
var prop = _prop() | ||
newPromisedProp(prop, store).then(prop) | ||
return prop | ||
} | ||
return _prop(store) | ||
} | ||
var roots = [], modules = [], controllers = [], lastRedrawId = 0, computePostRedrawHook = null, prevented = false | ||
@@ -414,6 +446,6 @@ m.module = function(root, module) { | ||
} | ||
m.redraw = function() { | ||
m.redraw = function(force) { | ||
var cancel = window.cancelAnimationFrame || window.clearTimeout | ||
var defer = window.requestAnimationFrame || window.setTimeout | ||
if (lastRedrawId) { | ||
if (lastRedrawId && force !== true) { | ||
cancel(lastRedrawId) | ||
@@ -495,3 +527,3 @@ lastRedrawId = defer(redraw, 0) | ||
var shouldReplaceHistoryEntry = (arguments.length == 3 ? arguments[2] : arguments[1]) === true | ||
if (window.history.pushState) { | ||
@@ -531,3 +563,3 @@ computePostRedrawHook = function() { | ||
var values = [].slice.call(arguments, 1, -2) | ||
for (var i = 0; i < keys.length; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeSpace(values[i]) | ||
for (var i = 0; i < keys.length; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i]) | ||
m.module(root, router[route]) | ||
@@ -574,46 +606,151 @@ }) | ||
var none = {} | ||
m.deferred = function() { | ||
var resolvers = [], rejecters = [], resolved = none, rejected = none, promise = m.prop() | ||
var object = { | ||
resolve: function(value) { | ||
if (resolved === none) promise(resolved = value) | ||
for (var i = 0; i < resolvers.length; i++) resolvers[i](value) | ||
resolvers.length = rejecters.length = 0 | ||
}, | ||
reject: function(value) { | ||
if (rejected === none) rejected = value | ||
for (var i = 0; i < rejecters.length; i++) rejecters[i](value) | ||
resolvers.length = rejecters.length = 0 | ||
}, | ||
promise: promise | ||
function newPromisedProp(prop, promise) { | ||
prop.then = function () { | ||
var newProp = m.prop() | ||
return newPromisedProp(newProp, | ||
promise.then.apply(promise, arguments).then(newProp)) | ||
} | ||
object.promise.resolvers = resolvers | ||
object.promise.then = function(success, error) { | ||
var next = m.deferred() | ||
if (!success) success = identity | ||
if (!error) error = identity | ||
function callback(method, callback) { | ||
return function(value) { | ||
try { | ||
var result = callback(value) | ||
if (result && typeof result.then == "function") result.then(next[method], error) | ||
else next[method](result !== undefined ? result : value) | ||
} | ||
catch (e) { | ||
if (type.call(e) == "[object Error]" && e.constructor !== Error) throw e | ||
else next.reject(e) | ||
} | ||
} | ||
prop.promise = prop | ||
prop.resolve = function (val) { | ||
prop(val) | ||
promise = promise.resolve.apply(promise, arguments) | ||
return prop | ||
} | ||
prop.reject = function () { | ||
promise = promise.reject.apply(promise, arguments) | ||
return prop | ||
} | ||
return prop | ||
} | ||
m.deferred = function () { | ||
return newPromisedProp(m.prop(), new Deferred()) | ||
} | ||
// Promiz.mithril.js | Zolmeister | MIT | ||
function Deferred(fn, er) { | ||
// states | ||
// 0: pending | ||
// 1: resolving | ||
// 2: rejecting | ||
// 3: resolved | ||
// 4: rejected | ||
var self = this, | ||
state = 0, | ||
val = 0, | ||
next = []; | ||
self['promise'] = self | ||
self['resolve'] = function (v) { | ||
if (!state) { | ||
val = v | ||
state = 1 | ||
fire() | ||
} | ||
if (resolved !== none) callback("resolve", success)(resolved) | ||
else if (rejected !== none) callback("reject", error)(rejected) | ||
return this | ||
} | ||
self['reject'] = function (v) { | ||
if (!state) { | ||
val = v | ||
state = 2 | ||
fire() | ||
} | ||
return this | ||
} | ||
self['then'] = function (fn, er) { | ||
var d = new Deferred(fn, er) | ||
if (state == 3) { | ||
d.resolve(val) | ||
} | ||
else if (state == 4) { | ||
d.reject(val) | ||
} | ||
else { | ||
resolvers.push(callback("resolve", success)) | ||
rejecters.push(callback("reject", error)) | ||
next.push(d) | ||
} | ||
return next.promise | ||
return d | ||
} | ||
return object | ||
var finish = function (type) { | ||
state = type || 4 | ||
next.map(function (p) { | ||
state == 3 && p.resolve(val) || p.reject(val) | ||
}) | ||
} | ||
// ref : reference to 'then' function | ||
// cb, ec, cn : successCallback, failureCallback, notThennableCallback | ||
function thennable (ref, cb, ec, cn) { | ||
if ((typeof val == 'object' || typeof val == 'function') && typeof ref == 'function') { | ||
try { | ||
// cnt protects against abuse calls from spec checker | ||
var cnt = 0 | ||
ref.call(val, function (v) { | ||
if (cnt++) return | ||
val = v | ||
cb() | ||
}, function (v) { | ||
if (cnt++) return | ||
val = v | ||
ec() | ||
}) | ||
} catch (e) { | ||
val = e | ||
ec() | ||
} | ||
} else { | ||
cn() | ||
} | ||
}; | ||
function fire() { | ||
// check if it's a thenable | ||
var ref; | ||
try { | ||
ref = val && val.then | ||
} catch (e) { | ||
val = e | ||
state = 2 | ||
return fire() | ||
} | ||
thennable(ref, function () { | ||
state = 1 | ||
fire() | ||
}, function () { | ||
state = 2 | ||
fire() | ||
}, function () { | ||
try { | ||
if (state == 1 && typeof fn == 'function') { | ||
val = fn(val) | ||
} | ||
else if (state == 2 && typeof er == 'function') { | ||
val = er(val) | ||
state = 1 | ||
} | ||
} catch (e) { | ||
val = e | ||
return finish() | ||
} | ||
if (val == self) { | ||
val = TypeError() | ||
finish() | ||
} else thennable(ref, function () { | ||
finish(3) | ||
}, finish, function () { | ||
finish(state == 1 && 3) | ||
}) | ||
}) | ||
} | ||
} | ||
m.sync = function(args) { | ||
@@ -642,3 +779,3 @@ var method = "resolve" | ||
else deferred.resolve() | ||
return deferred.promise | ||
@@ -662,3 +799,3 @@ } | ||
var maybeXhr = options.config(xhr, options) | ||
if (maybeXhr !== undefined) xhr = maybeXhr | ||
if (maybeXhr != null) xhr = maybeXhr | ||
} | ||
@@ -665,0 +802,0 @@ xhr.send(options.method == "GET" ? "" : options.data) |
/* | ||
Mithril v0.1.20 | ||
Mithril v0.1.21 | ||
http://github.com/lhorie/mithril.js | ||
@@ -7,3 +7,3 @@ (c) Leo Horie | ||
*/ | ||
Mithril=m=new function a(b,c){function d(){for(var a,b=arguments,d=(!(b[1]===c||"[object Object]"!=A.call(b[1])||"tag"in b[1]||"subtree"in b[1])),e=d?b[1]:{},f=("class"in e?"class":"className"),g={tag:"div",attrs:{}},h=[];a=B.exec(b[0]);)if(""==a[1])g.tag=a[2];else if("#"==a[1])g.attrs.id=a[2];else if("."==a[1])h.push(a[2]);else if("["==a[3][0]){var i=C.exec(a[3]);g.attrs[i[1]]=i[3]||(i[2]?"":!0)}h.length>0&&(g.attrs[f]=h.join(" ")),g.children=d?b[2]:b[1];for(var j in e)g.attrs[j]=j==f?(g.attrs[j]||"")+" "+e[j]:e[j];return g}function e(a,d,h,k,l,m,n,o,p,q,r){if((l===c||null===l)&&(l=""),"retain"===l.subtree)return m;var s=A.call(m),t=A.call(l);if(m===c||null===m||s!=t){if(null!==m&&m!==c)if(h&&h.nodes){var u=o-k,v=u+("[object Array]"==t?l:m.nodes).length;g(h.nodes.slice(u,v),h.slice(u,v))}else m.nodes&&g(m.nodes,m);m=new l.constructor,m.nodes=[]}if("[object Array]"==t){l=j(l);for(var w=[],x=m.length===l.length,y=0,z=1,B=2,C=3,D={},E=[],F=!1,G=0;G<m.length;G++)m[G]&&m[G].attrs&&m[G].attrs.key!==c&&(F=!0,D[m[G].attrs.key]={action:z,index:G});if(F){for(var G=0;G<l.length;G++)if(l[G]&&l[G].attrs)if(l[G].attrs.key!==c){var H=l[G].attrs.key;D[H]=D[H]?{action:C,index:G,from:D[H].index,element:a.childNodes[D[H].index]}:{action:B,index:G}}else E.push({index:G,element:a.childNodes[G]});for(var I,J=Object.keys(D).map(function(a){return D[a]}),K=J.sort(function(a,b){return a.action-b.action||a.index-b.index}),L=m.slice(),G=0;I=K[G];G++){if(I.action==z&&(g(m[I.index].nodes,m[I.index]),L.splice(I.index,1)),I.action==B){var M=b.document.createElement("div");M.key=l[I.index].attrs.key,a.insertBefore(M,a.childNodes[I.index]),L.splice(I.index,0,{attrs:{key:l[I.index].attrs.key},nodes:[M]})}I.action==C&&(a.childNodes[I.index]!==I.element&&null!==I.element&&a.insertBefore(I.element,a.childNodes[I.index]),L[I.index]=m[I.from])}for(var G=0;G<E.length;G++){var I=E[G];a.insertBefore(I.element,a.childNodes[I.index]),L[I.index]=m[I.index]}m=L,m.nodes=[];for(var N,G=0;N=a.childNodes[G];G++)m.nodes.push(N)}for(var G=0,O=0;G<l.length;G++){var P=e(a,d,m,o,l[G],m[O],n,o+y||y,p,q,r);if(P!==c){P.nodes.intact||(x=!1);var Q="[object Array]"==A.call(P);y+=Q?P.length:1,m[O++]=P}}if(!x){for(var G=0;G<l.length;G++)m[G]!==c&&(w=w.concat(m[G].nodes));for(var R,G=0;R=m.nodes[G];G++)null!==R.parentNode&&w.indexOf(R)<0&&R.parentNode.removeChild(R);for(var R,G=m.nodes.length;R=w[G];G++)null===R.parentNode&&a.appendChild(R);l.length<m.length&&(m.length=l.length),m.nodes=w}}else if(l!==c&&"[object Object]"==t){if((l.tag!=m.tag||Object.keys(l.attrs).join()!=Object.keys(m.attrs).join()||l.attrs.id!=m.attrs.id)&&(g(m.nodes),m.configContext&&"function"==typeof m.configContext.onunload&&m.configContext.onunload()),"string"!=typeof l.tag)return;var R,S=0===m.nodes.length;l.attrs.xmlns?q=l.attrs.xmlns:"svg"===l.tag?q="http://www.w3.org/2000/svg":"math"===l.tag&&(q="http://www.w3.org/1998/Math/MathML"),S?(R=q===c?b.document.createElement(l.tag):b.document.createElementNS(q,l.tag),m={tag:l.tag,children:l.children!==c?e(R,l.tag,c,c,l.children,m.children,!0,0,l.attrs.contenteditable?R:p,q,r):[],attrs:f(R,l.tag,l.attrs,{},q),nodes:[R]},a.insertBefore(R,a.childNodes[o]||null)):(R=m.nodes[0],f(R,l.tag,l.attrs,m.attrs,q),m.children=l.children!==c?e(R,l.tag,c,c,l.children,m.children,!1,0,l.attrs.contenteditable?R:p,q,r):[],m.nodes.intact=!0,n===!0&&null!==R&&a.insertBefore(R,a.childNodes[o]||null)),"function"==typeof l.attrs.config&&r.push(l.attrs.config.bind(b,R,!S,m.configContext=m.configContext||{},m))}else if("function"!=typeof t){var w;0===m.nodes.length?(l.$trusted?w=i(a,o,l):(w=[b.document.createTextNode(l)],a.insertBefore(w[0],a.childNodes[o]||null)),m="string number boolean".indexOf(typeof l)>-1?new l.constructor(l):l,m.nodes=w):m.valueOf()!==l.valueOf()||n===!0?(w=m.nodes,p&&p===b.document.activeElement||(l.$trusted?(g(w,m),w=i(a,o,l)):"textarea"===d?a.value=l:p?p.innerHTML=l:((1==w[0].nodeType||w.length>1)&&(g(m.nodes,m),w=[b.document.createTextNode(l)]),a.insertBefore(w[0],a.childNodes[o]||null),w[0].nodeValue=l)),m=new l.constructor(l),m.nodes=w):m.nodes.intact=!0}return m}function f(a,d,e,f,g){for(var h in e){var i=e[h],j=f[h];if(!(h in f)||j!==i||a===b.document.activeElement){if(f[h]=i,"config"===h)continue;if("function"==typeof i&&0==h.indexOf("on"))a[h]=k(i,a);else if("style"===h&&"object"==typeof i){for(var l in i)(j===c||j[l]!==i[l])&&(a.style[l]=i[l]);for(var l in j)l in i||(a.style[l]="")}else g!==c?"href"===h?a.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===h?a.setAttribute("class",i):a.setAttribute(h,i):"value"===h&&"input"===d?a.value!==i&&(a.value=i):h in a&&"list"!=h&&"style"!=h?a[h]=i:a.setAttribute(h,i)}}return f}function g(a,b){for(var c=a.length-1;c>-1;c--)a[c]&&a[c].parentNode&&(a[c].parentNode.removeChild(a[c]),b=[].concat(b),b[c]&&h(b[c]));0!=a.length&&(a.length=0)}function h(a){if(a.configContext&&"function"==typeof a.configContext.onunload&&a.configContext.onunload(),a.children)if("[object Array]"==A.call(a.children))for(var b=0;b<a.children.length;b++)h(a.children[b]);else a.children.tag&&h(a.children)}function i(a,c,d){var e=a.childNodes[c];if(e){var f=1!=e.nodeType,g=b.document.createElement("span");f?(a.insertBefore(g,e),g.insertAdjacentHTML("beforebegin",d),a.removeChild(g)):e.insertAdjacentHTML("beforebegin",d)}else a.insertAdjacentHTML("beforeend",d);for(var h=[];a.childNodes[c]!==e;)h.push(a.childNodes[c]),c++;return h}function j(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];"[object Array]"==A.call(d)?b.push.apply(b,j(d)):b.push(d)}return b}function k(a,b){return function(c){c=c||event,d.redraw.strategy("diff"),d.startComputation();try{return a.call(b,c)}finally{J||(J=-1),d.endComputation()}}}function l(a){var b=E.indexOf(a);return 0>b?E.push(a)-1:b}function m(){for(var a=d.redraw.strategy(),b=0;b<G.length;b++)I[b]&&"none"!=a&&d.render(G[b],H[b].view(I[b]),"all"==a);K&&(K(),K=null),J=null,d.redraw.strategy("diff")}function n(a){return a.slice(N[d.route.mode].length)}function o(a,b,c){P={};var e=c.indexOf("?");-1!==e&&(P=s(c.substr(e+1,c.length)),c=c.substr(0,e));for(var f in b){if(f==c)return d.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)||[],e=[].slice.call(arguments,1,-2),g=0;g<c.length;g++)P[c[g].replace(/:|\./g,"")]=t(e[g]);d.module(a,b[f])}),!0}}function p(a){a=a||event,a.ctrlKey||a.metaKey||2==a.which||(a.preventDefault(),d.route(a.currentTarget[d.route.mode].slice(N[d.route.mode].length)))}function q(){"hash"!=d.route.mode&&b.location.hash?b.location.hash=b.location.hash:b.scrollTo(0,0)}function r(a,b){var c=[];for(var d in a){var e=b?b+"["+d+"]":d,f=a[d];c.push("object"==typeof f?r(f,e):encodeURIComponent(e)+"="+encodeURIComponent(f))}return c.join("&")}function s(a){for(var b=a.split("&"),c={},d=0;d<b.length;d++){var e=b[d].split("=");c[t(e[0])]=e[1]?t(e[1]):1===e.length?!0:""}return c}function t(a){return decodeURIComponent(a.replace(/\+/g," "))}function u(a){var b=l(a);g(a.childNodes,F[b]),F[b]=c}function v(a){return a}function w(a){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&&"GET"!=a.method&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof a.config){var e=a.config(d,a);e!==c&&(d=e)}return d.send("GET"==a.method?"":a.data),d}function x(a,b,c){return b&&Object.keys(b).length>0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+r(b):a.data=c(b)),a}function y(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 z,A={}.toString,B=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,C=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,D={insertAdjacentHTML:function(a,c){b.document.write(c),b.document.close()},appendChild:function(a){z===c&&(z=b.document.createElement("html")),"HTML"==a.nodeName?z=a:z.appendChild(a),b.document.documentElement&&b.document.documentElement!==z?b.document.replaceChild(z,b.document.documentElement):b.document.appendChild(z)},insertBefore:function(a){this.appendChild(a)},childNodes:[]},E=[],F={};d.render=function(a,d,f){var h=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var i=l(a),j=a==b.document||a==b.document.documentElement?D:a;F[i]===c&&g(j.childNodes),f===!0&&u(a),F[i]=e(j,null,c,c,d,F[i],!1,0,null,c,h);for(var k=0;k<h.length;k++)h[k]()},d.trust=function(a){return a=new String(a),a.$trusted=!0,a},d.prop=function(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b};var G=[],H=[],I=[],J=0,K=null;d.module=function(a,b){var c=G.indexOf(a);0>c&&(c=G.length);var e=!1;if(I[c]&&"function"==typeof I[c].onunload){var f={preventDefault:function(){e=!0}};I[c].onunload(f)}e||(d.redraw.strategy("all"),d.startComputation(),G[c]=a,H[c]=b,I[c]=new b.controller,d.endComputation())},d.redraw=function(){var a=b.cancelAnimationFrame||b.clearTimeout,c=b.requestAnimationFrame||b.setTimeout;J?(a(J),J=c(m,0)):(m(),J=c(function(){J=null},0))},d.redraw.strategy=d.prop();var L=0;d.startComputation=function(){L++},d.endComputation=function(){L=Math.max(L-1,0),0==L&&d.redraw()},d.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 M,N={pathname:"",hash:"#",search:"?"},O=function(){},P={};d.route=function(){if(0===arguments.length)return M;if(3===arguments.length&&"string"==typeof arguments[1]){var a=arguments[0],c=arguments[1],e=arguments[2];O=function(b){var f=M=n(b);o(a,e,f)||d.route(c,!0)};var f="hash"==d.route.mode?"onhashchange":"onpopstate";b[f]=function(){M!=n(b.location[d.route.mode])&&O(b.location[d.route.mode])},K=q,b[f]()}else if(arguments[0].addEventListener){var g=arguments[0],h=arguments[1];g.href.indexOf(N[d.route.mode])<0&&(g.href=b.location.pathname+N[d.route.mode]+g.pathname),h||(g.removeEventListener("click",p),g.addEventListener("click",p))}else if("string"==typeof arguments[0]){M=arguments[0];var i="object"==typeof arguments[1]?r(arguments[1]):null;i&&(M+=(-1===M.indexOf("?")?"?":"&")+i);var j=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(K=function(){b.history[j?"replaceState":"pushState"](null,b.document.title,N[d.route.mode]+M),q()},O(N[d.route.mode]+M)):b.location[d.route.mode]=M}},d.route.param=function(a){return P[a]},d.route.mode="search";var Q={};return d.deferred=function(){var a=[],b=[],e=Q,f=Q,g=d.prop(),h={resolve:function(c){e===Q&&g(e=c);for(var d=0;d<a.length;d++)a[d](c);a.length=b.length=0},reject:function(c){f===Q&&(f=c);for(var d=0;d<b.length;d++)b[d](c);a.length=b.length=0},promise:g};return h.promise.resolvers=a,h.promise.then=function(g,h){function i(a,b){return function(d){try{var e=b(d);e&&"function"==typeof e.then?e.then(j[a],h):j[a](e!==c?e:d)}catch(f){if("[object Error]"==A.call(f)&&f.constructor!==Error)throw f;j.reject(f)}}}var j=d.deferred();return g||(g=v),h||(h=v),e!==Q?i("resolve",g)(e):f!==Q?i("reject",h)(f):(a.push(i("resolve",g)),b.push(i("reject",h))),j.promise},h},d.sync=function(a){function b(a,b){return function(d){return g[a]=d,b||(c="reject"),0==--f&&(e.promise(g),e[c](g)),d}}var c="resolve",e=d.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 e.resolve();return e.promise},d.request=function(a){a.background!==!0&&d.startComputation();var b=d.deferred(),c=a.serialize=a.serialize||JSON.stringify,e=a.deserialize=a.deserialize||JSON.parse,f=a.extract||function(a){return 0===a.responseText.length&&e===JSON.parse?null:a.responseText};return a.url=y(a.url,a.data),a=x(a,a.data,c),a.onload=a.onerror=function(c){try{c=c||event;var g=("load"==c.type?a.unwrapSuccess:a.unwrapError)||v,h=g(e(f(c.target,a)));if("load"==c.type)if("[object Array]"==A.call(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){if(c instanceof SyntaxError)throw new SyntaxError("Could not parse HTTP response. See http://lhorie.github.io/mithril/mithril.request.html#using-variable-data-formats");if("[object Error]"==A.call(c)&&c.constructor!==Error)throw c;b.reject(c)}a.background!==!0&&d.endComputation()},w(a),b.promise},d.deps=function(a){return b=a},d.deps.factory=a,d}("undefined"!=typeof window?window:{}),"undefined"!=typeof module&&null!==module&&(module.exports=m),"function"==typeof define&&define.amd&&define(function(){return m}); | ||
Mithril=m=new function a(b,c){function d(){for(var a,b=arguments,c=(!(null==b[1]||"[object Object]"!=D.call(b[1])||"tag"in b[1]||"subtree"in b[1])),d=c?b[1]:{},e=("class"in d?"class":"className"),f={tag:"div",attrs:{}},g=[];a=E.exec(b[0]);)if(""==a[1])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=F.exec(a[3]);f.attrs[h[1]]=h[3]||(h[2]?"":!0)}g.length>0&&(f.attrs[e]=g.join(" ")),f.children=c?b[2]:b[1];for(var i in d)f.attrs[i]=i==e?(f.attrs[i]||"")+" "+d[i]:d[i];return f}function e(a,d,h,k,l,m,n,o,p,q,r){if(null==l&&(l=""),"retain"===l.subtree)return m;var s=D.call(m),t=D.call(l);if(null==m||s!=t){if(null!=m)if(h&&h.nodes){var u=o-k,v=u+("[object Array]"==t?l:m.nodes).length;g(h.nodes.slice(u,v),h.slice(u,v))}else m.nodes&&g(m.nodes,m);m=new l.constructor,m.nodes=[]}if("[object Array]"==t){l=j(l);for(var w=[],x=m.length===l.length,y=0,z=1,A=2,B=3,C={},E=[],F=!1,H=0;H<m.length;H++)m[H]&&m[H].attrs&&null!=m[H].attrs.key&&(F=!0,C[m[H].attrs.key]={action:z,index:H});if(F){for(var H=0;H<l.length;H++)if(l[H]&&l[H].attrs)if(null!=l[H].attrs.key){var I=l[H].attrs.key;C[I]=C[I]?{action:B,index:H,from:C[I].index,element:a.childNodes[C[I].index]}:{action:A,index:H}}else E.push({index:H,element:a.childNodes[H]});for(var J,K=Object.keys(C).map(function(a){return C[a]}),L=K.sort(function(a,b){return a.action-b.action||a.index-b.index}),M=m.slice(),H=0;J=L[H];H++){if(J.action==z&&(g(m[J.index].nodes,m[J.index]),M.splice(J.index,1)),J.action==A){var N=b.document.createElement("div");N.key=l[J.index].attrs.key,a.insertBefore(N,a.childNodes[J.index]),M.splice(J.index,0,{attrs:{key:l[J.index].attrs.key},nodes:[N]})}J.action==B&&(a.childNodes[J.index]!==J.element&&null!==J.element&&a.insertBefore(J.element,a.childNodes[J.index]),M[J.index]=m[J.from])}for(var H=0;H<E.length;H++){var J=E[H];a.insertBefore(J.element,a.childNodes[J.index]),M[J.index]=m[J.index]}m=M,m.nodes=[];for(var O,H=0;O=a.childNodes[H];H++)m.nodes.push(O)}for(var H=0,P=0;H<l.length;H++){var Q=e(a,d,m,o,l[H],m[P],n,o+y||y,p,q,r);if(Q!==c){Q.nodes.intact||(x=!1);var R="[object Array]"==D.call(Q);y+=R?Q.length:1,m[P++]=Q}}if(!x){for(var H=0;H<l.length;H++)null!=m[H]&&(w=w.concat(m[H].nodes));for(var S,H=0;S=m.nodes[H];H++)null!=S.parentNode&&w.indexOf(S)<0&&g([S],[m[H]]);for(var S,H=m.nodes.length;S=w[H];H++)null==S.parentNode&&a.appendChild(S);l.length<m.length&&(m.length=l.length),m.nodes=w}}else if(null!=l&&"[object Object]"==t){if((l.tag!=m.tag||Object.keys(l.attrs).join()!=Object.keys(m.attrs).join()||l.attrs.id!=m.attrs.id)&&(g(m.nodes),m.configContext&&"function"==typeof m.configContext.onunload&&m.configContext.onunload()),"string"!=typeof l.tag)return;var S,T=0===m.nodes.length;l.attrs.xmlns?q=l.attrs.xmlns:"svg"===l.tag?q="http://www.w3.org/2000/svg":"math"===l.tag&&(q="http://www.w3.org/1998/Math/MathML"),T?(S=q===c?b.document.createElement(l.tag):b.document.createElementNS(q,l.tag),m={tag:l.tag,children:e(S,l.tag,c,c,l.children,m.children,!0,0,l.attrs.contenteditable?S:p,q,r),attrs:f(S,l.tag,l.attrs,{},q),nodes:[S]},a.insertBefore(S,a.childNodes[o]||null)):(S=m.nodes[0],f(S,l.tag,l.attrs,m.attrs,q),m.children=e(S,l.tag,c,c,l.children,m.children,!1,0,l.attrs.contenteditable?S:p,q,r),m.nodes.intact=!0,n===!0&&null!=S&&a.insertBefore(S,a.childNodes[o]||null)),"function"==typeof l.attrs.config&&r.push(l.attrs.config.bind(b,S,!T,m.configContext=m.configContext||{},m))}else if("function"!=typeof t){var w;0===m.nodes.length?(l.$trusted?w=i(a,o,l):(w=[b.document.createTextNode(l)],a.nodeName.match(G)||a.insertBefore(w[0],a.childNodes[o]||null)),m="string number boolean".indexOf(typeof l)>-1?new l.constructor(l):l,m.nodes=w):m.valueOf()!==l.valueOf()||n===!0?(w=m.nodes,p&&p===b.document.activeElement||(l.$trusted?(g(w,m),w=i(a,o,l)):"textarea"===d?a.value=l:p?p.innerHTML=l:((1==w[0].nodeType||w.length>1)&&(g(m.nodes,m),w=[b.document.createTextNode(l)]),a.insertBefore(w[0],a.childNodes[o]||null),w[0].nodeValue=l)),m=new l.constructor(l),m.nodes=w):m.nodes.intact=!0}return m}function f(a,c,d,e,f){for(var g in d){var h=d[g],i=e[g];if(!(g in e)||i!==h||a===b.document.activeElement){if(e[g]=h,"config"===g)continue;if("function"==typeof h&&0==g.indexOf("on"))a[g]=k(h,a);else if("style"===g&&"object"==typeof h){for(var j in h)(null==i||i[j]!==h[j])&&(a.style[j]=h[j]);for(var j in i)j in h||(a.style[j]="")}else null!=f?"href"===g?a.setAttributeNS("http://www.w3.org/1999/xlink","href",h):"className"===g?a.setAttribute("class",h):a.setAttribute(g,h):"value"===g&&"input"===c?a.value!==h&&(a.value=h):g in a&&"list"!=g&&"style"!=g?a[g]=h:a.setAttribute(g,h)}}return e}function g(a,b){for(var c=a.length-1;c>-1;c--)a[c]&&a[c].parentNode&&(a[c].parentNode.removeChild(a[c]),b=[].concat(b),b[c]&&h(b[c]));0!=a.length&&(a.length=0)}function h(a){if(a.configContext&&"function"==typeof a.configContext.onunload&&a.configContext.onunload(),a.children)if("[object Array]"==D.call(a.children))for(var b=0;b<a.children.length;b++)h(a.children[b]);else a.children.tag&&h(a.children)}function i(a,c,d){var e=a.childNodes[c];if(e){var f=1!=e.nodeType,g=b.document.createElement("span");f?(a.insertBefore(g,e),g.insertAdjacentHTML("beforebegin",d),a.removeChild(g)):e.insertAdjacentHTML("beforebegin",d)}else a.insertAdjacentHTML("beforeend",d);for(var h=[];a.childNodes[c]!==e;)h.push(a.childNodes[c]),c++;return h}function j(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];"[object Array]"==D.call(d)?b.push.apply(b,j(d)):b.push(d)}return b}function k(a,b){return function(c){c=c||event,d.redraw.strategy("diff"),d.startComputation();try{return a.call(b,c)}finally{N||(N=-1),d.endComputation()}}}function l(a){var b=I.indexOf(a);return 0>b?I.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=d.redraw.strategy(),b=0;b<K.length;b++)M[b]&&"none"!=a&&d.render(K[b],L[b].view(M[b]),"all"==a);O&&(O(),O=null),N=null,d.redraw.strategy("diff")}function o(a){return a.slice(R[d.route.mode].length)}function p(a,b,c){T={};var e=c.indexOf("?");-1!==e&&(T=t(c.substr(e+1,c.length)),c=c.substr(0,e));for(var f in b){if(f==c)return d.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)||[],e=[].slice.call(arguments,1,-2),g=0;g<c.length;g++)T[c[g].replace(/:|\./g,"")]=decodeURIComponent(e[g]);d.module(a,b[f])}),!0}}function q(a){a=a||event,a.ctrlKey||a.metaKey||2==a.which||(a.preventDefault(),d.route(a.currentTarget[d.route.mode].slice(R[d.route.mode].length)))}function r(){"hash"!=d.route.mode&&b.location.hash?b.location.hash=b.location.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("object"==typeof f?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]):1===e.length?!0:""}return c}function u(a){return decodeURIComponent(a.replace(/\+/g," "))}function v(a){var b=l(a);g(a.childNodes,J[b]),J[b]=c}function w(a,b){return a.then=function(){var a=d.prop();return w(a,b.then.apply(b,arguments).then(a))},a.promise=a,a.resolve=function(c){return a(c),b=b.resolve.apply(b,arguments),a},a.reject=function(){return b=b.reject.apply(b,arguments),a},a}function x(a,b){function c(a,b,c,d){if("object"!=typeof g&&"function"!=typeof g||"function"!=typeof a)d();else try{var e=0;a.call(g,function(a){e++||(g=a,b())},function(a){e++||(g=a,c())})}catch(f){g=f,c()}}function d(){var h;try{h=g&&g.then}catch(j){return g=j,f=2,d()}c(h,function(){f=1,d()},function(){f=2,d()},function(){try{1==f&&"function"==typeof a?g=a(g):2==f&&"function"==typeof b&&(g=b(g),f=1)}catch(d){return g=d,i()}g==e?(g=TypeError(),i()):c(h,function(){i(3)},i,function(){i(1==f&&3)})})}var e=this,f=0,g=0,h=[];e.promise=e,e.resolve=function(a){return f||(g=a,f=1,d()),this},e.reject=function(a){return f||(g=a,f=2,d()),this},e.then=function(a,b){var c=new x(a,b);return 3==f?c.resolve(g):4==f?c.reject(g):h.push(c),c};var i=function(a){f=a||4,h.map(function(a){3==f&&a.resolve(g)||a.reject(g)})}}function y(a){return a}function z(a){var c=new b.XMLHttpRequest;if(c.open(a.method,a.url,!0,a.user,a.password),c.onreadystatechange=function(){4===c.readyState&&(c.status>=200&&c.status<300?a.onload({type:"load",target:c}):a.onerror({type:"error",target:c}))},a.serialize==JSON.stringify&&"GET"!=a.method&&c.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof a.config){var d=a.config(c,a);null!=d&&(c=d)}return c.send("GET"==a.method?"":a.data),c}function A(a,b,c){return b&&Object.keys(b).length>0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+s(b):a.data=c(b)),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={}.toString,E=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,F=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,G=/AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR/,H={insertAdjacentHTML:function(a,c){b.document.write(c),b.document.close()},appendChild:function(a){C===c&&(C=b.document.createElement("html")),"HTML"==a.nodeName?C=a:C.appendChild(a),b.document.documentElement&&b.document.documentElement!==C?b.document.replaceChild(C,b.document.documentElement):b.document.appendChild(C)},insertBefore:function(a){this.appendChild(a)},childNodes:[]},I=[],J={};d.render=function(a,d,f){var h=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var i=l(a),j=a==b.document||a==b.document.documentElement?H:a;J[i]===c&&g(j.childNodes),f===!0&&v(a),J[i]=e(j,null,c,c,d,J[i],!1,0,null,c,h);for(var k=0;k<h.length;k++)h[k]()},d.trust=function(a){return a=new String(a),a.$trusted=!0,a},d.prop=function(a){if(("object"==typeof a||"function"==typeof a)&&"function"==typeof a.then){var b=m();return w(b,a).then(b),b}return m(a)};var K=[],L=[],M=[],N=0,O=null;d.module=function(a,b){var c=K.indexOf(a);0>c&&(c=K.length);var e=!1;if(M[c]&&"function"==typeof M[c].onunload){var f={preventDefault:function(){e=!0}};M[c].onunload(f)}e||(d.redraw.strategy("all"),d.startComputation(),K[c]=a,L[c]=b,M[c]=new b.controller,d.endComputation())},d.redraw=function(a){var c=b.cancelAnimationFrame||b.clearTimeout,d=b.requestAnimationFrame||b.setTimeout;N&&a!==!0?(c(N),N=d(n,0)):(n(),N=d(function(){N=null},0))},d.redraw.strategy=d.prop();var P=0;d.startComputation=function(){P++},d.endComputation=function(){P=Math.max(P-1,0),0==P&&d.redraw()},d.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 Q,R={pathname:"",hash:"#",search:"?"},S=function(){},T={};return d.route=function(){if(0===arguments.length)return Q;if(3===arguments.length&&"string"==typeof arguments[1]){var a=arguments[0],c=arguments[1],e=arguments[2];S=function(b){var f=Q=o(b);p(a,e,f)||d.route(c,!0)};var f="hash"==d.route.mode?"onhashchange":"onpopstate";b[f]=function(){Q!=o(b.location[d.route.mode])&&S(b.location[d.route.mode])},O=r,b[f]()}else if(arguments[0].addEventListener){var g=arguments[0],h=arguments[1];g.href.indexOf(R[d.route.mode])<0&&(g.href=b.location.pathname+R[d.route.mode]+g.pathname),h||(g.removeEventListener("click",q),g.addEventListener("click",q))}else if("string"==typeof arguments[0]){Q=arguments[0];var i="object"==typeof arguments[1]?s(arguments[1]):null;i&&(Q+=(-1===Q.indexOf("?")?"?":"&")+i);var j=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(O=function(){b.history[j?"replaceState":"pushState"](null,b.document.title,R[d.route.mode]+Q),r()},S(R[d.route.mode]+Q)):b.location[d.route.mode]=Q}},d.route.param=function(a){return T[a]},d.route.mode="search",d.deferred=function(){return w(d.prop(),new x)},d.sync=function(a){function b(a,b){return function(d){return g[a]=d,b||(c="reject"),0==--f&&(e.promise(g),e[c](g)),d}}var c="resolve",e=d.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 e.resolve();return e.promise},d.request=function(a){a.background!==!0&&d.startComputation();var b=d.deferred(),c=a.serialize=a.serialize||JSON.stringify,e=a.deserialize=a.deserialize||JSON.parse,f=a.extract||function(a){return 0===a.responseText.length&&e===JSON.parse?null:a.responseText};return a.url=B(a.url,a.data),a=A(a,a.data,c),a.onload=a.onerror=function(c){try{c=c||event;var g=("load"==c.type?a.unwrapSuccess:a.unwrapError)||y,h=g(e(f(c.target,a)));if("load"==c.type)if("[object Array]"==D.call(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){if(c instanceof SyntaxError)throw new SyntaxError("Could not parse HTTP response. See http://lhorie.github.io/mithril/mithril.request.html#using-variable-data-formats");if("[object Error]"==D.call(c)&&c.constructor!==Error)throw c;b.reject(c)}a.background!==!0&&d.endComputation()},z(a),b.promise},d.deps=function(a){return b=a},d.deps.factory=a,d}("undefined"!=typeof window?window:{}),"undefined"!=typeof module&&null!==module&&(module.exports=m),"function"==typeof define&&define.amd&&define(function(){return m}); | ||
//# sourceMappingURL=mithril.min.map |
@@ -5,3 +5,3 @@ { | ||
"keywords": ["mvc", "framework"], | ||
"version": "0.1.20", | ||
"version": "0.1.21", | ||
"author": "Leo Horie <leohorie@hotmail.com>", | ||
@@ -8,0 +8,0 @@ "repository": {"type": "git", "url": "https://github.com/lhorie/mithril"}, |
Sorry, the diff of this file is not supported yet
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
65968
846