Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mithril

Package Overview
Dependencies
Maintainers
1
Versions
160
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mithril - npm Package Compare versions

Comparing version 0.1.22 to 0.1.23

195

mithril.js
Mithril = m = new function app(window, undefined) {
var sObj = "[object Object]", sArr = "[object Array]", sStr = "[object String]"
function type(obj) {return {}.toString.call(obj)}
function isObj(obj) {return type(obj) == sObj}
function isArr(obj) {return type(obj) == sArr}
function isFn(obj) {return typeof obj == "function"}
function isStr(obj){ return type(obj) == sStr}
var sObj = "[object Object]", sArr = "[object Array]", sStr = "[object String]", sFn = "function"
var type = {}.toString
var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/
var voidElements = /AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TR‌​ACK|WBR/
var voidElements = /AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR/

@@ -25,5 +21,4 @@ /*

function m() {
var arrSlice = Array.prototype.slice;
var args = arrSlice.call(arguments, 0)
var hasAttrs = args[1] != null && isObj(args[1]) && !("tag" in args[1]) && !("subtree" in args[1])
var args = [].slice.call(arguments)
var hasAttrs = args[1] != null && type.call(args[1]) == sObj && !("tag" in args[1]) && !("subtree" in args[1])
var attrs = hasAttrs ? args[1] : {}

@@ -34,3 +29,3 @@ var classAttrName = "class" in attrs ? "class" : "className"

while (match = parser.exec(args[0])) {
if (match[1] == "") cell.tag = match[2]
if (match[1] == "" && match[2]) cell.tag = match[2]
else if (match[1] == "#") cell.attrs.id = match[2]

@@ -47,4 +42,4 @@ else if (match[1] == ".") classes.push(match[2])

var children = hasAttrs ? args[2] : args[1]
if (isArr(children) || type(children) == "[object Arguments]") {
cell.children = arrSlice.call(children, 0)
if (type.call(children) == sArr) {
cell.children = children
}

@@ -89,3 +84,3 @@ else {

if (data.subtree === "retain") return cached
var cachedType = type(cached), dataType = type(data)
var cachedType = type.call(cached), dataType = type.call(data)
if (cached == null || cachedType != dataType) {

@@ -151,3 +146,3 @@ if (cached != null) {

dummy.key = data[change.index].attrs.key
parentElement.insertBefore(dummy, parentElement.childNodes[change.index])
parentElement.insertBefore(dummy, parentElement.childNodes[change.index] || null)
newCached.splice(change.index, 0, {attrs: {key: data[change.index].attrs.key}, nodes: [dummy]})

@@ -158,3 +153,3 @@ }

if (parentElement.childNodes[change.index] !== change.element && change.element !== null) {
parentElement.insertBefore(change.element, parentElement.childNodes[change.index])
parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null)
}

@@ -166,3 +161,3 @@ newCached[change.index] = cached[change.from]

var change = unkeyed[i]
parentElement.insertBefore(change.element, parentElement.childNodes[change.index])
parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null)
newCached[change.index] = cached[change.index]

@@ -181,3 +176,9 @@ }

if (!item.nodes.intact) intact = false
subArrayCount += isArr(item) ? item.length : 1
if (item.$trusted) {
//fix offset of next element if item was a trusted string w/ more than one html element
//the first clause in the regexp matches elements
//the second clause (after the pipe) matches text nodes
subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || []).length
}
else subArrayCount += type.call(item) == sArr ? item.length : 1
cached[cacheCount++] = item

@@ -206,8 +207,12 @@ }

else if (data != null && dataType == sObj) {
if (!data.attrs) data.attrs = {}
if (!cached.attrs) cached.attrs = {}
var dataAttrKeys = Object.keys(data.attrs)
//if an element is different enough from the one in cache, recreate it
if (data.tag != cached.tag || Object.keys(data.attrs).join() != Object.keys(cached.attrs).join() || data.attrs.id != cached.attrs.id) {
clear(cached.nodes)
if (cached.configContext && isFn(cached.configContext.onunload)) cached.configContext.onunload()
if (data.tag != cached.tag || dataAttrKeys.join() != Object.keys(cached.attrs).join() || data.attrs.id != cached.attrs.id) {
if (cached.nodes.length) clear(cached.nodes)
if (cached.configContext && typeof cached.configContext.onunload == sFn) cached.configContext.onunload()
}
if (!isStr(data.tag)) return
if (type.call(data.tag) != sStr) return

@@ -219,10 +224,15 @@ var node, isNew = cached.nodes.length === 0

if (isNew) {
node = namespace === undefined ? window.document.createElement(data.tag) : window.document.createElementNS(namespace, data.tag)
node = namespace === undefined ? window.document.createElement(data.tag, data.attrs.is) : window.document.createElementNS(namespace, data.tag, data.attrs.is)
cached = {
tag: data.tag,
//process children before attrs so that select.value works correctly
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),
//set attributes first, then create children
attrs: dataAttrKeys.length ? setAttributes(node, data.tag, data.attrs, {}, namespace) : {},
children: data.children != null && data.children.length > 0 ?
build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) :
data.children,
nodes: [node]
}
if (cached.children && !cached.children.nodes) cached.children.nodes = []
//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)
parentElement.insertBefore(node, parentElement.childNodes[index] || null)

@@ -232,3 +242,3 @@ }

node = cached.nodes[0]
setAttributes(node, data.tag, data.attrs, cached.attrs, namespace)
if (dataAttrKeys.length) setAttributes(node, data.tag, data.attrs, cached.attrs, namespace)
cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs)

@@ -239,3 +249,3 @@ cached.nodes.intact = true

//schedule configs to be called. They are called after `build` finishes running
if (isFn(data.attrs["config"])) {
if (typeof data.attrs["config"] == sFn) {
var context = cached.configContext = cached.configContext || {}

@@ -252,3 +262,3 @@

}
else if (!isFn(dataType)) {
else if (typeof dataType != sFn) {
//handle text nodes

@@ -308,7 +318,7 @@ var nodes

//hook event handlers to the auto-redrawing system
else if (isFn(dataAttr) && attrName.indexOf("on") == 0) {
else if (typeof dataAttr == sFn && attrName.indexOf("on") == 0) {
node[attrName] = autoredraw(dataAttr, node)
}
//handle `style: {...}`
else if (attrName === "style" && isObj(dataAttr)) {
else if (attrName === "style" && dataAttr != null && type.call(dataAttr) == sObj) {
for (var rule in dataAttr) {

@@ -331,10 +341,3 @@ if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule]

else if (attrName in node && !(attrName == "list" || attrName == "style" || attrName == "form")) {
//FIXME: don't clobber value if still typing (see #151 and #214)
//it appears browsers work like this:
//- user types, updates UI immediately
//- event handler, however, does NOT fire immediately if there's javascript running (because js is single threaded)
//- once js finishes, then it runs rAF callback, which clobbers the input if we're using naive bidirectional bindings
//- THEN it fires the event handler with the new input value
//so if the input value is updated during the small window between registering a UI change natively and the end of non-idle js time, the input loses the value update from that event
if (!(node === window.document.activeElement && attrName == "value")) node[attrName] = dataAttr
node[attrName] = dataAttr
}

@@ -348,2 +351,5 @@ else node.setAttribute(attrName, dataAttr)

}
else if (attrName === "value" && tag === "input" && node.value !== dataAttr) {
node.value = dataAttr
}
}

@@ -363,5 +369,5 @@ return cachedAttrs

function unload(cached) {
if (cached.configContext && isFn(cached.configContext.onunload)) cached.configContext.onunload()
if (cached.configContext && typeof cached.configContext.onunload == sFn) cached.configContext.onunload()
if (cached.children) {
if (isArr(cached.children)) {
if (type.call(cached.children) == sArr) {
for (var i = 0; i < cached.children.length; i++) unload(cached.children[i])

@@ -378,3 +384,3 @@ }

if (isElement) {
parentElement.insertBefore(placeholder, nextSibling)
parentElement.insertBefore(placeholder, nextSibling || null)
placeholder.insertAdjacentHTML("beforebegin", data)

@@ -394,9 +400,15 @@ parentElement.removeChild(placeholder)

function flatten(data) {
var flattened = []
for (var i = 0; i < data.length; i++) {
var item = data[i]
if (isArr(item)) flattened.push.apply(flattened, flatten(item))
else flattened.push(item)
var index = 0
loop: while (true) {
for (var i = index; i < data.length; i++) {
var item = data[i]
if (type.call(data[i]) == sArr) {
index = i
data = data.concat.apply([], data)
continue loop
}
}
break
}
return flattened
return data
}

@@ -410,5 +422,2 @@ function autoredraw(callback, object) {

finally {
//FIXME: force asynchronous redraw for event handlers, to prevent double redraw in cases like onkeypress+oninput (#151)
//this solution isn't ideal because it creates a small window of opportunity for events to get lost (see #214).
if (!lastRedrawId) lastRedrawId = -1
m.endComputation()

@@ -472,3 +481,4 @@ }

m.prop = function (store) {
if ((isObj(store) || isFn(store)) && store !== null && isFn(store.then)) {
//note: using non-strict equality check here because we're checking if store is null OR undefined
if (((store != null && type.call(store) == sObj) || typeof store == sFn) && typeof store.then == sFn) {
return propify(store)

@@ -480,3 +490,3 @@ }

var roots = [], modules = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePostRedrawHook = null, prevented = false
var roots = [], modules = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePostRedrawHook = null, prevented = false, topModule
var FRAME_BUDGET = 16 //60 frames per second = 1 call per 16 ms

@@ -487,3 +497,3 @@ m.module = function(root, module) {

var isPrevented = false
if (controllers[index] && isFn(controllers[index].onunload)) {
if (controllers[index] && typeof controllers[index].onunload == sFn) {
var event = {

@@ -498,4 +508,10 @@ preventDefault: function() {isPrevented = true}

roots[index] = root
modules[index] = module
controllers[index] = new module.controller
var currentModule = topModule = module
var controller = new module.controller
//controllers may call m.module recursively (via m.route redirects, for example)
//this conditional ensures only the last recursive m.module call is applied
if (currentModule == topModule) {
controllers[index] = controller
modules[index] = module
}
m.endComputation()

@@ -509,3 +525,2 @@ return controllers[index]

//lastRedrawId is a positive number if a second redraw is requested before the next animation frame
//lastRedrawId is -1 if the redraw is the first one in a event handler (see #151)
//lastRedrawID is null if it's the first redraw and not an event handler

@@ -529,3 +544,5 @@ if (lastRedrawId && force !== true) {

for (var i = 0; i < roots.length; i++) {
if (controllers[i] && mode != "none") m.render(roots[i], modules[i].view(controllers[i]), mode == "all")
if (controllers[i] && mode != "none") {
m.render(roots[i], modules[i].view(controllers[i]), mode == "all")
}
}

@@ -561,4 +578,5 @@ //after rendering within a routed context, we need to scroll back to the top, and fetch the document title for history.pushState

m.route = function() {
//m.route()
if (arguments.length === 0) return currentRoute
else if (arguments.length === 3 && isStr(arguments[1])) {
else if (arguments.length === 3 && type.call(arguments[1]) == sStr) {
var root = arguments[0], defaultRoute = arguments[1], router = arguments[2]

@@ -580,2 +598,3 @@ redirect = function(source) {

}
//config: m.route
else if (arguments[0].addEventListener) {

@@ -585,12 +604,10 @@ var element = arguments[0]

var context = arguments[2]
if (!isInitialized) {
context.href = element.getAttribute("href")
element.href = window.location.pathname + modes[m.route.mode] + context.href
element.removeEventListener("click", routeUnobtrusive)
element.addEventListener("click", routeUnobtrusive)
}
element.href = (m.route.mode !== 'pathname' ? window.location.pathname : '') + modes[m.route.mode] + this.attrs.href
element.removeEventListener("click", routeUnobtrusive)
element.addEventListener("click", routeUnobtrusive)
}
else if (isStr(arguments[0])) {
//m.route(route)
else if (type.call(arguments[0]) == sStr) {
currentRoute = arguments[0]
var querystring = isObj(arguments[1]) ? buildQueryString(arguments[1]) : null
var querystring = arguments[1] != null && type.call(arguments[1]) == sObj ? buildQueryString(arguments[1]) : null
if (querystring) currentRoute += (currentRoute.indexOf("?") === -1 ? "?" : "&") + querystring

@@ -647,3 +664,4 @@

var currentTarget = e.currentTarget || this
m.route(currentTarget[m.route.mode].slice(modes[m.route.mode].length))
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)
}

@@ -658,3 +676,3 @@ function setScroll() {

var key = prefix ? prefix + "[" + prop + "]" : prop, value = object[prop]
str.push(isObj(value) ? buildQueryString(value, key) : encodeURIComponent(key) + "=" + encodeURIComponent(value))
str.push(value != null && type.call(value) == sObj ? buildQueryString(value, key) : encodeURIComponent(key) + "=" + encodeURIComponent(value))
}

@@ -686,3 +704,3 @@ return str.join("&")

function propify(promise) {
prop = m.prop()
var prop = m.prop()
promise.then(prop)

@@ -746,3 +764,3 @@ prop.then = function(resolve, reject) {

function thennable(then, successCallback, failureCallback, notThennableCallback) {
if ((isObj(promiseValue) || isFn(promiseValue)) && isFn(then)) {
if (((promiseValue != null && type.call(promiseValue) == sObj) || typeof promiseValue == sFn) && typeof then == sFn) {
try {

@@ -791,6 +809,6 @@ // count protects against abuse calls from spec checker

try {
if (state == RESOLVING && isFn(successCallback)) {
if (state == RESOLVING && typeof successCallback == sFn) {
promiseValue = successCallback(promiseValue)
}
else if (state == REJECTING && isFn(failureCallback)) {
else if (state == REJECTING && typeof failureCallback == "function") {
promiseValue = failureCallback(promiseValue)

@@ -821,3 +839,3 @@ state = RESOLVING

m.deferred.onerror = function(e) {
if (type(e) == "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e
if (type.call(e) == "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e
}

@@ -847,3 +865,3 @@

}
else deferred.resolve()
else deferred.resolve([])

@@ -858,5 +876,4 @@ return deferred.promise

var script = window.document.createElement("script")
window[callbackKey] = function(resp){
delete window[callbackKey]
window[callbackKey] = function(resp) {
window.document.body.removeChild(script)

@@ -869,6 +886,6 @@ options.onload({

})
window[callbackKey] = undefined
}
script.onerror = function(e) {
delete window[callbackKey]
window.document.body.removeChild(script)

@@ -883,2 +900,3 @@

})
window[callbackKey] = undefined

@@ -892,3 +910,2 @@ return false

script.src = options.url

@@ -916,3 +933,3 @@ + (options.url.indexOf("?") > 0 ? "&" : "?")

}
if (isFn(options.config)) {
if (typeof options.config == sFn) {
var maybeXhr = options.config(xhr, options)

@@ -922,2 +939,3 @@ if (maybeXhr != null) xhr = maybeXhr

if (options.data && (type.call(options.data) != sStr && options.data.constructor != window.FormData)) throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`"
xhr.send(options.method == "GET" || !options.data ? "" : options.data)

@@ -928,8 +946,8 @@ return xhr

function bindData(xhrOptions, data, serialize) {
if (data && Object.keys(data).length > 0) {
if (xhrOptions.method == "GET") {
xhrOptions.url = xhrOptions.url + (xhrOptions.url.indexOf("?") < 0 ? "?" : "&") + buildQueryString(data)
}
else xhrOptions.data = serialize(data)
if (xhrOptions.method == "GET" && xhrOptions.dataType != "jsonp") {
var prefix = xhrOptions.url.indexOf("?") < 0 ? "?" : "&"
var querystring = buildQueryString(data)
xhrOptions.url = xhrOptions.url + (querystring ? prefix + querystring : "")
}
else xhrOptions.data = serialize(data)
return xhrOptions

@@ -966,3 +984,3 @@ }

if (e.type == "load") {
if (isArr(response) && xhrOptions.type) {
if (type.call(response) == sArr && xhrOptions.type) {
for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i])

@@ -981,2 +999,3 @@ }

ajax(xhrOptions)
deferred.promise(xhrOptions.initialValue)
return deferred.promise

@@ -986,3 +1005,3 @@ }

//testing API
m.deps = function(mock) {return window = mock}
m.deps = function(mock) {return window = mock || window}
//for internal testing only, do not use `m.deps.factory`

@@ -989,0 +1008,0 @@ m.deps.factory = app

/*
Mithril v0.1.22
Mithril v0.1.23
http://github.com/lhorie/mithril.js

@@ -7,3 +7,3 @@ (c) Leo Horie

*/
Mithril=m=new function a(b,c){function d(a){return{}.toString.call(a)}function e(a){return d(a)==I}function f(a){return d(a)==J}function g(a){return"function"==typeof a}function h(a){return d(a)==K}function i(){for(var a,b=Array.prototype.slice,c=b.call(arguments,0),g=(!(null==c[1]||!e(c[1])||"tag"in c[1]||"subtree"in c[1])),h=g?c[1]:{},i=("class"in h?"class":"className"),j={tag:"div",attrs:{}},k=[];a=L.exec(c[0]);)if(""==a[1])j.tag=a[2];else if("#"==a[1])j.attrs.id=a[2];else if("."==a[1])k.push(a[2]);else if("["==a[3][0]){var l=M.exec(a[3]);j.attrs[l[1]]=l[3]||(l[2]?"":!0)}k.length>0&&(j.attrs[i]=k.join(" "));var m=g?c[2]:c[1];j.children=f(m)||"[object Arguments]"==d(m)?b.call(m,0):c.slice(g?2:1);for(var n in h)j.attrs[n]=n==i?(j.attrs[n]||"")+" "+h[n]:h[n];return j}function j(a,e,i,m,p,q,r,s,t,u,v){if(null==p&&(p=""),"retain"===p.subtree)return q;var w=d(q),x=d(p);if(null==q||w!=x){if(null!=q)if(i&&i.nodes){var y=s-m,z=y+(x==J?p:q.nodes).length;l(i.nodes.slice(y,z),i.slice(y,z))}else q.nodes&&l(q.nodes,q);q=new p.constructor,q.tag&&(q={}),q.nodes=[]}if(x==J){p=o(p);for(var A=[],B=q.length===p.length,C=0,D=1,E=2,F=3,G={},H=[],K=!1,L=0;L<q.length;L++)q[L]&&q[L].attrs&&null!=q[L].attrs.key&&(K=!0,G[q[L].attrs.key]={action:D,index:L});if(K){for(var L=0;L<p.length;L++)if(p[L]&&p[L].attrs)if(null!=p[L].attrs.key){var M=p[L].attrs.key;G[M]=G[M]?{action:F,index:L,from:G[M].index,element:a.childNodes[G[M].index]||b.document.createElement("div")}:{action:E,index:L}}else H.push({index:L,element:a.childNodes[L]||b.document.createElement("div")});for(var O,P=Object.keys(G).map(function(a){return G[a]}),Q=P.sort(function(a,b){return a.action-b.action||a.index-b.index}),R=q.slice(),L=0;O=Q[L];L++){if(O.action==D&&(l(q[O.index].nodes,q[O.index]),R.splice(O.index,1)),O.action==E){var S=b.document.createElement("div");S.key=p[O.index].attrs.key,a.insertBefore(S,a.childNodes[O.index]),R.splice(O.index,0,{attrs:{key:p[O.index].attrs.key},nodes:[S]})}O.action==F&&(a.childNodes[O.index]!==O.element&&null!==O.element&&a.insertBefore(O.element,a.childNodes[O.index]),R[O.index]=q[O.from])}for(var L=0;L<H.length;L++){var O=H[L];a.insertBefore(O.element,a.childNodes[O.index]),R[O.index]=q[O.index]}q=R,q.nodes=[];for(var T,L=0;T=a.childNodes[L];L++)q.nodes.push(T)}for(var L=0,U=0;L<p.length;L++){var V=j(a,e,q,s,p[L],q[U],r,s+C||C,t,u,v);V!==c&&(V.nodes.intact||(B=!1),C+=f(V)?V.length:1,q[U++]=V)}if(!B){for(var L=0;L<p.length;L++)null!=q[L]&&(A=A.concat(q[L].nodes));for(var W,L=0;W=q.nodes[L];L++)null!=W.parentNode&&A.indexOf(W)<0&&l([W],[q[L]]);for(var W,L=q.nodes.length;W=A[L];L++)null==W.parentNode&&a.appendChild(W);p.length<q.length&&(q.length=p.length),q.nodes=A}}else if(null!=p&&x==I){if((p.tag!=q.tag||Object.keys(p.attrs).join()!=Object.keys(q.attrs).join()||p.attrs.id!=q.attrs.id)&&(l(q.nodes),q.configContext&&g(q.configContext.onunload)&&q.configContext.onunload()),!h(p.tag))return;var W,X=0===q.nodes.length;if(p.attrs.xmlns?u=p.attrs.xmlns:"svg"===p.tag?u="http://www.w3.org/2000/svg":"math"===p.tag&&(u="http://www.w3.org/1998/Math/MathML"),X?(W=u===c?b.document.createElement(p.tag):b.document.createElementNS(u,p.tag),q={tag:p.tag,children:j(W,p.tag,c,c,p.children,q.children,!0,0,p.attrs.contenteditable?W:t,u,v),attrs:k(W,p.tag,p.attrs,{},u),nodes:[W]},a.insertBefore(W,a.childNodes[s]||null)):(W=q.nodes[0],k(W,p.tag,p.attrs,q.attrs,u),q.children=j(W,p.tag,c,c,p.children,q.children,!1,0,p.attrs.contenteditable?W:t,u,v),q.nodes.intact=!0,r===!0&&null!=W&&a.insertBefore(W,a.childNodes[s]||null)),g(p.attrs.config)){var Y=q.configContext=q.configContext||{},Z=function(a,b){return function(){return a.attrs.config.apply(a,b)}};v.push(Z(p,[W,!X,Y,q]))}}else if(!g(x)){var A;0===q.nodes.length?(p.$trusted?A=n(a,s,p):(A=[b.document.createTextNode(p)],a.nodeName.match(N)||a.insertBefore(A[0],a.childNodes[s]||null)),q="string number boolean".indexOf(typeof p)>-1?new p.constructor(p):p,q.nodes=A):q.valueOf()!==p.valueOf()||r===!0?(A=q.nodes,t&&t===b.document.activeElement||(p.$trusted?(l(A,q),A=n(a,s,p)):"textarea"===e?a.value=p:t?t.innerHTML=p:((1==A[0].nodeType||A.length>1)&&(l(q.nodes,q),A=[b.document.createTextNode(p)]),a.insertBefore(A[0],a.childNodes[s]||null),A[0].nodeValue=p)),q=new p.constructor(p),q.nodes=A):q.nodes.intact=!0}return q}function k(a,c,d,f,h){for(var i in d){var j=d[i],k=f[i];if(!(i in f)||k!==j){f[i]=j;try{if("config"===i)continue;if(g(j)&&0==i.indexOf("on"))a[i]=p(j,a);else if("style"===i&&e(j)){for(var l in j)(null==k||k[l]!==j[l])&&(a.style[l]=j[l]);for(var l in k)l in j||(a.style[l]="")}else null!=h?"href"===i?a.setAttributeNS("http://www.w3.org/1999/xlink","href",j):"className"===i?a.setAttribute("class",j):a.setAttribute(i,j):i in a&&"list"!=i&&"style"!=i&&"form"!=i?(a!==b.document.activeElement||"value"!=i)&&(a[i]=j):a.setAttribute(i,j)}catch(m){if(m.message.indexOf("Invalid argument")<0)throw m}}}return f}function l(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]&&m(b[c]));0!=a.length&&(a.length=0)}function m(a){if(a.configContext&&g(a.configContext.onunload)&&a.configContext.onunload(),a.children)if(f(a.children))for(var b=0;b<a.children.length;b++)m(a.children[b]);else a.children.tag&&m(a.children)}function n(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 o(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];f(d)?b.push.apply(b,o(d)):b.push(d)}return b}function p(a,b){return function(c){c=c||event,i.redraw.strategy("diff"),i.startComputation();try{return a.call(b,c)}finally{U||(U=-1),i.endComputation()}}}function q(a){var b=P.indexOf(a);return 0>b?P.push(a)-1:b}function r(a){var b=function(){return arguments.length&&(a=arguments[0]),a};return b.toJSON=function(){return a},b}function s(){for(var a=i.redraw.strategy(),b=0;b<R.length;b++)T[b]&&"none"!=a&&i.render(R[b],S[b].view(T[b]),"all"==a);W&&(W(),W=null),U=null,V=new Date,i.redraw.strategy("diff")}function t(a){return a.slice($[i.route.mode].length)}function u(a,b,c){ab={};var d=c.indexOf("?");-1!==d&&(ab=y(c.substr(d+1,c.length)),c=c.substr(0,d));for(var e in b){if(e==c)return i.module(a,b[e]),!0;var f=new RegExp("^"+e.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(f.test(c))return c.replace(f,function(){for(var c=e.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),f=0;f<c.length;f++)ab[c[f].replace(/:|\./g,"")]=decodeURIComponent(d[f]);i.module(a,b[e])}),!0}}function v(a){if(a=a||event,!a.ctrlKey&&!a.metaKey&&2!=a.which){a.preventDefault?a.preventDefault():a.returnValue=!1;var b=a.currentTarget||this;i.route(b[i.route.mode].slice($[i.route.mode].length))}}function w(){"hash"!=i.route.mode&&b.location.hash?b.location.hash=b.location.hash:b.scrollTo(0,0)}function x(a,b){var c=[];for(var d in a){var f=b?b+"["+d+"]":d,g=a[d];c.push(e(g)?x(g,f):encodeURIComponent(f)+"="+encodeURIComponent(g))}return c.join("&")}function y(a){for(var b=a.split("&"),c={},d=0;d<b.length;d++){var e=b[d].split("=");c[z(e[0])]=e[1]?z(e[1]):1===e.length?!0:""}return c}function z(a){return decodeURIComponent(a.replace(/\+/g," "))}function A(a){var b=q(a);l(a.childNodes,Q[b]),Q[b]=c}function B(a){return prop=i.prop(),a.then(prop),prop.then=function(b,c){return B(a.then(b,c))},prop}function C(a,b){function c(a){n=a||l,p.map(function(a){n==k&&a.resolve(o)||a.reject(o)})}function d(a,b,c,d){if((e(o)||g(o))&&g(a))try{var f=0;a.call(o,function(a){f++||(o=a,b())},function(a){f++||(o=a,c())})}catch(h){i.deferred.onerror(h),o=h,c()}else d()}function f(){var e;try{e=o&&o.then}catch(l){return i.deferred.onerror(l),o=l,n=j,f()}d(e,function(){n=h,f()},function(){n=j,f()},function(){try{n==h&&g(a)?o=a(o):n==j&&g(b)&&(o=b(o),n=h)}catch(f){return i.deferred.onerror(f),o=f,c()}o==m?(o=TypeError(),c()):d(e,function(){c(k)},c,function(){c(n==h&&k)})})}var h=1,j=2,k=3,l=4,m=this,n=0,o=0,p=[];m.promise={},m.resolve=function(a){return n||(o=a,n=h,f()),this},m.reject=function(a){return n||(o=a,n=j,f()),this},m.promise.then=function(a,b){var c=new C(a,b);return n==k?c.resolve(o):n==l?c.reject(o):p.push(c),c.promise}}function D(a){return a}function E(a){if(!a.dataType||"jsonp"!==a.dataType.toLowerCase()){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&&a.data&&"GET"!=a.method&&c.setRequestHeader("Content-Type","application/json; charset=utf-8"),a.deserialize==JSON.parse&&c.setRequestHeader("Accept","application/json, text/*"),g(a.config)){var d=a.config(c,a);null!=d&&(c=d)}return c.send("GET"!=a.method&&a.data?a.data:""),c}var e="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),f=b.document.createElement("script");b[e]=function(c){delete b[e],b.document.body.removeChild(f),a.onload({type:"load",target:{responseText:c}})},f.onerror=function(){return delete b[e],b.document.body.removeChild(f),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),!1},f.onload=function(){return!1},f.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+e+"&"+x(a.data||{}),b.document.body.appendChild(f)}function F(a,b,c){return b&&Object.keys(b).length>0&&("GET"==a.method?a.url=a.url+(a.url.indexOf("?")<0?"?":"&")+x(b):a.data=c(b)),a}function G(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 H,I="[object Object]",J="[object Array]",K="[object String]",L=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,M=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,N=/AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TR‌​ACK|WBR/,O={appendChild:function(a){H===c&&(H=b.document.createElement("html")),b.document.documentElement&&b.document.documentElement!==a?b.document.replaceChild(a,b.document.documentElement):b.document.appendChild(a),this.childNodes=b.document.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},P=[],Q={};i.render=function(a,d,e){var f=[];if(!a)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var g=q(a),h=a==b.document,i=h||a==b.document.documentElement?O:a;h&&"html"!=d.tag&&(d={tag:"html",attrs:{},children:d}),Q[g]===c&&l(i.childNodes),e===!0&&A(a),Q[g]=j(i,null,c,c,d,Q[g],!1,0,null,c,f);for(var k=0;k<f.length;k++)f[k]()},i.trust=function(a){return a=new String(a),a.$trusted=!0,a},i.prop=function(a){return(e(a)||g(a))&&null!==a&&g(a.then)?B(a):r(a)};var R=[],S=[],T=[],U=null,V=0,W=null,X=16;i.module=function(a,b){var c=R.indexOf(a);0>c&&(c=R.length);var d=!1;if(T[c]&&g(T[c].onunload)){var e={preventDefault:function(){d=!0}};T[c].onunload(e)}return d?void 0:(i.redraw.strategy("all"),i.startComputation(),R[c]=a,S[c]=b,T[c]=new b.controller,i.endComputation(),T[c])},i.redraw=function(a){var c=b.cancelAnimationFrame||b.clearTimeout,d=b.requestAnimationFrame||b.setTimeout;U&&a!==!0?(new Date-V>X||d==b.requestAnimationFrame)&&(U>0&&c(U),U=d(s,X)):(s(),U=d(function(){U=null},X))},i.redraw.strategy=i.prop();var Y=0;i.startComputation=function(){Y++},i.endComputation=function(){Y=Math.max(Y-1,0),0==Y&&i.redraw()},i.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 Z,$={pathname:"",hash:"#",search:"?"},_=function(){},ab={};return i.route=function(){if(0===arguments.length)return Z;if(3===arguments.length&&h(arguments[1])){var a=arguments[0],c=arguments[1],d=arguments[2];_=function(b){var e=Z=t(b);u(a,d,e)||i.route(c,!0)};var f="hash"==i.route.mode?"onhashchange":"onpopstate";b[f]=function(){Z!=t(b.location[i.route.mode])&&_(b.location[i.route.mode])},W=w,b[f]()}else if(arguments[0].addEventListener){var g=arguments[0],j=arguments[1],k=arguments[2];j||(k.href=g.getAttribute("href"),g.href=b.location.pathname+$[i.route.mode]+k.href,g.removeEventListener("click",v),g.addEventListener("click",v))}else if(h(arguments[0])){Z=arguments[0];var l=e(arguments[1])?x(arguments[1]):null;l&&(Z+=(-1===Z.indexOf("?")?"?":"&")+l);var m=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(W=function(){b.history[m?"replaceState":"pushState"](null,b.document.title,$[i.route.mode]+Z),w()},_($[i.route.mode]+Z)):b.location[i.route.mode]=Z}},i.route.param=function(a){return ab[a]},i.route.mode="search",i.deferred=function(){var a=new C;return a.promise=B(a.promise),a},i.deferred.onerror=function(a){if("[object Error]"==d(a)&&!a.constructor.toString().match(/ Error/))throw a},i.sync=function(a){function b(a,b){return function(g){return f[a]=g,b||(c="reject"),0==--e&&(d.promise(f),d[c](f)),g}}var c="resolve",d=i.deferred(),e=a.length,f=new Array(e);if(a.length>0)for(var g=0;g<a.length;g++)a[g].then(b(g,!0),b(g,!1));else d.resolve();return d.promise},i.request=function(a){a.background!==!0&&i.startComputation();var b=i.deferred(),c=a.dataType&&"jsonp"===a.dataType.toLowerCase(),d=a.serialize=c?D:a.serialize||JSON.stringify,e=a.deserialize=c?D:a.deserialize||JSON.parse,g=a.extract||function(a){return 0===a.responseText.length&&e===JSON.parse?null:a.responseText};return a.url=G(a.url,a.data),a=F(a,a.data,d),a.onload=a.onerror=function(c){try{c=c||event;var d=("load"==c.type?a.unwrapSuccess:a.unwrapError)||D,h=d(e(g(c.target,a)));if("load"==c.type)if(f(h)&&a.type)for(var j=0;j<h.length;j++)h[j]=new a.type(h[j]);else a.type&&(h=new a.type(h));b["load"==c.type?"resolve":"reject"](h)}catch(c){i.deferred.onerror(c),b.reject(c)}a.background!==!0&&i.endComputation()},E(a),b.promise},i.deps=function(a){return b=a},i.deps.factory=a,i}("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
Mithril=m=new function a(b,c){function d(){for(var a,b=[].slice.call(arguments),c=(!(null==b[1]||H.call(b[1])!=D||"tag"in b[1]||"subtree"in b[1])),d=c?b[1]:{},e=("class"in d?"class":"className"),f={tag:"div",attrs:{}},g=[];a=I.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=J.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=H.call(i)==E?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 e(a,d,h,k,l,m,n,o,p,q,r){if(null==l&&(l=""),"retain"===l.subtree)return m;var s=H.call(m),t=H.call(l);if(null==m||s!=t){if(null!=m)if(h&&h.nodes){var u=o-k,v=u+(t==E?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.tag&&(m={}),m.nodes=[]}if(t==E){l=j(l);for(var w=[],x=m.length===l.length,y=0,z=1,A=2,B=3,C={},I=[],J=!1,L=0;L<m.length;L++)m[L]&&m[L].attrs&&null!=m[L].attrs.key&&(J=!0,C[m[L].attrs.key]={action:z,index:L});if(J){for(var L=0;L<l.length;L++)if(l[L]&&l[L].attrs)if(null!=l[L].attrs.key){var M=l[L].attrs.key;C[M]=C[M]?{action:B,index:L,from:C[M].index,element:a.childNodes[C[M].index]||b.document.createElement("div")}:{action:A,index:L}}else I.push({index:L,element:a.childNodes[L]||b.document.createElement("div")});for(var N,O=Object.keys(C).map(function(a){return C[a]}),P=O.sort(function(a,b){return a.action-b.action||a.index-b.index}),Q=m.slice(),L=0;N=P[L];L++){if(N.action==z&&(g(m[N.index].nodes,m[N.index]),Q.splice(N.index,1)),N.action==A){var R=b.document.createElement("div");R.key=l[N.index].attrs.key,a.insertBefore(R,a.childNodes[N.index]||null),Q.splice(N.index,0,{attrs:{key:l[N.index].attrs.key},nodes:[R]})}N.action==B&&(a.childNodes[N.index]!==N.element&&null!==N.element&&a.insertBefore(N.element,a.childNodes[N.index]||null),Q[N.index]=m[N.from])}for(var L=0;L<I.length;L++){var N=I[L];a.insertBefore(N.element,a.childNodes[N.index]||null),Q[N.index]=m[N.index]}m=Q,m.nodes=[];for(var S,L=0;S=a.childNodes[L];L++)m.nodes.push(S)}for(var L=0,T=0;L<l.length;L++){var U=e(a,d,m,o,l[L],m[T],n,o+y||y,p,q,r);U!==c&&(U.nodes.intact||(x=!1),y+=U.$trusted?(U.match(/<[^\/]|\>\s*[^<]/g)||[]).length:H.call(U)==E?U.length:1,m[T++]=U)}if(!x){for(var L=0;L<l.length;L++)null!=m[L]&&(w=w.concat(m[L].nodes));for(var V,L=0;V=m.nodes[L];L++)null!=V.parentNode&&w.indexOf(V)<0&&g([V],[m[L]]);for(var V,L=m.nodes.length;V=w[L];L++)null==V.parentNode&&a.appendChild(V);l.length<m.length&&(m.length=l.length),m.nodes=w}}else if(null!=l&&t==D){l.attrs||(l.attrs={}),m.attrs||(m.attrs={});var W=Object.keys(l.attrs);if((l.tag!=m.tag||W.join()!=Object.keys(m.attrs).join()||l.attrs.id!=m.attrs.id)&&(m.nodes.length&&g(m.nodes),m.configContext&&typeof m.configContext.onunload==G&&m.configContext.onunload()),H.call(l.tag)!=F)return;var V,X=0===m.nodes.length;if(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"),X?(V=q===c?b.document.createElement(l.tag,l.attrs.is):b.document.createElementNS(q,l.tag,l.attrs.is),m={tag:l.tag,attrs:W.length?f(V,l.tag,l.attrs,{},q):{},children:null!=l.children&&l.children.length>0?e(V,l.tag,c,c,l.children,m.children,!0,0,l.attrs.contenteditable?V:p,q,r):l.children,nodes:[V]},m.children&&!m.children.nodes&&(m.children.nodes=[]),"select"==l.tag&&l.attrs.value&&f(V,l.tag,{value:l.attrs.value},{},q),a.insertBefore(V,a.childNodes[o]||null)):(V=m.nodes[0],W.length&&f(V,l.tag,l.attrs,m.attrs,q),m.children=e(V,l.tag,c,c,l.children,m.children,!1,0,l.attrs.contenteditable?V:p,q,r),m.nodes.intact=!0,n===!0&&null!=V&&a.insertBefore(V,a.childNodes[o]||null)),typeof l.attrs.config==G){var Y=m.configContext=m.configContext||{},Z=function(a,b){return function(){return a.attrs.config.apply(a,b)}};r.push(Z(l,[V,!X,Y,m]))}}else if(typeof t!=G){var w;0===m.nodes.length?(l.$trusted?w=i(a,o,l):(w=[b.document.createTextNode(l)],a.nodeName.match(K)||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,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==G&&0==f.indexOf("on"))a[f]=k(g,a);else if("style"===f&&null!=g&&H.call(g)==D){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?a[f]=g:a.setAttribute(f,g)}catch(j){if(j.message.indexOf("Invalid argument")<0)throw j}}}return d}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&&typeof a.configContext.onunload==G&&a.configContext.onunload(),a.children)if(H.call(a.children)==E)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||null),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){var b=0;a:for(;;){for(var c=b;c<a.length;c++){{a[c]}if(H.call(a[c])==E){b=c,a=a.concat.apply([],a);continue a}}break}return a}function k(a,b){return function(c){c=c||event,d.redraw.strategy("diff"),d.startComputation();try{return a.call(b,c)}finally{d.endComputation()}}}function l(a){var b=M.indexOf(a);return 0>b?M.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<P.length;b++)R[b]&&"none"!=a&&d.render(P[b],Q[b].view(R[b]),"all"==a);U&&(U(),U=null),S=null,T=new Date,d.redraw.strategy("diff")}function o(a){return a.slice(Y[d.route.mode].length)}function p(a,b,c){$={};var e=c.indexOf("?");-1!==e&&($=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++)$[c[g].replace(/:|\./g,"")]=decodeURIComponent(e[g]);d.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"==d.route.mode&&b.search?t(b.search.slice(1)):{};d.route(b[d.route.mode].slice(Y[d.route.mode].length),c)}}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(null!=f&&H.call(f)==D?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,N[b]),N[b]=c}function w(a){var b=d.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 e(a,b,c,e){if((null!=m&&H.call(m)==D||typeof m==G)&&typeof a==G)try{var f=0;a.call(m,function(a){f++||(m=a,b())},function(a){f++||(m=a,c())})}catch(g){d.deferred.onerror(g),m=g,c()}else e()}function f(){var j;try{j=m&&m.then}catch(n){return d.deferred.onerror(n),m=n,l=h,f()}e(j,function(){l=g,f()},function(){l=h,f()},function(){try{l==g&&typeof a==G?m=a(m):l==h&&"function"==typeof b&&(m=b(m),l=g)}catch(f){return d.deferred.onerror(f),m=f,c()}m==k?(m=TypeError(),c()):e(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==G){var e=a.config(d,a);null!=e&&(d=e)}if(a.data&&H.call(a.data)!=F&&a.data.constructor!=b.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return d.send("GET"!=a.method&&a.data?a.data:""),d}var f="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),g=b.document.createElement("script");b[f]=function(d){b.document.body.removeChild(g),a.onload({type:"load",target:{responseText:d}}),b[f]=c},g.onerror=function(){return b.document.body.removeChild(g),a.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),b[f]=c,!1},g.onload=function(){return!1},g.src=a.url+(a.url.indexOf("?")>0?"&":"?")+(a.callbackKey?a.callbackKey:"callback")+"="+f+"&"+s(a.data||{}),b.document.body.appendChild(g)}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="[object Object]",E="[object Array]",F="[object String]",G="function",H={}.toString,I=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,J=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,K=/AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR/,L={appendChild:function(a){C===c&&(C=b.document.createElement("html")),b.document.documentElement&&b.document.documentElement!==a?b.document.replaceChild(a,b.document.documentElement):b.document.appendChild(a),this.childNodes=b.document.childNodes},insertBefore:function(a){this.appendChild(a)},childNodes:[]},M=[],N={};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,k=j||a==b.document.documentElement?L:a;j&&"html"!=d.tag&&(d={tag:"html",attrs:{},children:d}),N[i]===c&&g(k.childNodes),f===!0&&v(a),N[i]=e(k,null,c,c,d,N[i],!1,0,null,c,h);for(var m=0;m<h.length;m++)h[m]()},d.trust=function(a){return a=new String(a),a.$trusted=!0,a},d.prop=function(a){return(null!=a&&H.call(a)==D||typeof a==G)&&typeof a.then==G?w(a):m(a)};var O,P=[],Q=[],R=[],S=null,T=0,U=null,V=16;d.module=function(a,b){var c=P.indexOf(a);0>c&&(c=P.length);var e=!1;if(R[c]&&typeof R[c].onunload==G){var f={preventDefault:function(){e=!0}};R[c].onunload(f)}if(!e){d.redraw.strategy("all"),d.startComputation(),P[c]=a;var g=O=b,h=new b.controller;return g==O&&(R[c]=h,Q[c]=b),d.endComputation(),R[c]}},d.redraw=function(a){var c=b.cancelAnimationFrame||b.clearTimeout,d=b.requestAnimationFrame||b.setTimeout;S&&a!==!0?(new Date-T>V||d==b.requestAnimationFrame)&&(S>0&&c(S),S=d(n,V)):(n(),S=d(function(){S=null},V))},d.redraw.strategy=d.prop();var W=0;d.startComputation=function(){W++},d.endComputation=function(){W=Math.max(W-1,0),0==W&&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 X,Y={pathname:"",hash:"#",search:"?"},Z=function(){},$={};return d.route=function(){if(0===arguments.length)return X;if(3===arguments.length&&H.call(arguments[1])==F){var a=arguments[0],c=arguments[1],e=arguments[2];Z=function(b){var f=X=o(b);p(a,e,f)||d.route(c,!0)};var f="hash"==d.route.mode?"onhashchange":"onpopstate";b[f]=function(){X!=o(b.location[d.route.mode])&&Z(b.location[d.route.mode])},U=r,b[f]()}else if(arguments[0].addEventListener){{var g=arguments[0];arguments[1],arguments[2]}g.href=("pathname"!==d.route.mode?b.location.pathname:"")+Y[d.route.mode]+this.attrs.href,g.removeEventListener("click",q),g.addEventListener("click",q)}else if(H.call(arguments[0])==F){X=arguments[0];var h=null!=arguments[1]&&H.call(arguments[1])==D?s(arguments[1]):null;h&&(X+=(-1===X.indexOf("?")?"?":"&")+h);var i=(3==arguments.length?arguments[2]:arguments[1])===!0;b.history.pushState?(U=function(){b.history[i?"replaceState":"pushState"](null,b.document.title,Y[d.route.mode]+X),r()},Z(Y[d.route.mode]+X)):b.location[d.route.mode]=X}},d.route.param=function(a){return $[a]},d.route.mode="search",d.deferred=function(){var a=new x;return a.promise=w(a.promise),a},d.deferred.onerror=function(a){if("[object Error]"==H.call(a)&&!a.constructor.toString().match(/ Error/))throw a},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.dataType&&"jsonp"===a.dataType.toLowerCase(),e=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,e),a.onload=a.onerror=function(c){try{c=c||event;var e=("load"==c.type?a.unwrapSuccess:a.unwrapError)||y,h=e(f(g(c.target,a)));if("load"==c.type)if(H.call(h)==E&&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){d.deferred.onerror(c),b.reject(c)}a.background!==!0&&d.endComputation()},z(a),b.promise(a.initialValue),b.promise},d.deps=function(a){return b=a||b},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.js.map

@@ -5,3 +5,3 @@ {

"keywords": ["mvc", "framework"],
"version": "0.1.22",
"version": "0.1.23",
"author": "Leo Horie <leohorie@hotmail.com>",

@@ -8,0 +8,0 @@ "repository": {"type": "git", "url": "https://github.com/lhorie/mithril"},

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc