New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mithril

Package Overview
Dependencies
Maintainers
2
Versions
163
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 1.0.0 to 1.0.1

LICENSE

2

api/redraw.js

@@ -31,3 +31,3 @@ "use strict"

})
var callbacks = []

@@ -34,0 +34,0 @@ function subscribe(key, callback) {

@@ -17,4 +17,5 @@ "use strict"

}
var bail = function() {
routeService.setPath(defaultRoute, null, {replace: true})
var bail = function(path) {
if (path !== defaultRoute) routeService.setPath(defaultRoute, null, {replace: true})
else throw new Error("Could not resolve default route " + defaultRoute)
}

@@ -21,0 +22,0 @@ routeService.defineRoutes(routes, function(payload, params, path) {

@@ -111,3 +111,3 @@ "use strict"

})
o("redraws when render function is executed", function() {

@@ -114,0 +114,0 @@ var onupdate = o.spy()

@@ -105,2 +105,2 @@ # Animations

It's also recommended that you avoid the `box-shadow` rule and selectors like `:nth-child`, since these are also resource intensive options. Other things that can be expensive include large or dynamically scaled images and overlapping elements with different `position` values (e.g. an absolute postioned element over a fixed element).
It's also recommended that you avoid the `box-shadow` rule and selectors like `:nth-child`, since these are also resource intensive options. If you want to animate a `box-shadow`, consider [putting the `box-shadow` rule on a pseudo element, and animate that element's opacity instead](http://tobiasahlin.com/blog/how-to-animate-box-shadow/). Other things that can be expensive include large or dynamically scaled images and overlapping elements with different `position` values (e.g. an absolute postioned element over a fixed element).

@@ -92,3 +92,3 @@ # The auto-redraw system

Mithril does not redraw after `setTimeout`, `setInterval`, `requestAnimationFrame` and 3rd party library event handlers (e.g. Socket.io callbacks). In those cases, you must manually call [`m.redraw()`](redraw.md).
Mithril does not redraw after `setTimeout`, `setInterval`, `requestAnimationFrame`, raw `Promise` resolutions and 3rd party library event handlers (e.g. Socket.io callbacks). In those cases, you must manually call [`m.redraw()`](redraw.md).

@@ -95,0 +95,0 @@ Mithril also does not redraw after lifecycle methods. Parts of the UI may be redrawn after an `oninit` handler, but other parts of the UI may already have been redrawn when a given `oninit` handler fires. Handlers like `oncreate` and `onupdate` fire after the UI has been redrawn.

# Change log
- [v1.0.1](#v101)
- [Migrating from v0.2.x](#migrating-from-v02x)
- [Older docs](http://mithril.js.org/archive/v0.2.5/change-log.html)
- [Older docs](http://mithril.js.org/archive/v0.2.5/index.html)
---
### v1.0.1
#### News
- performance improvements in IE [#1598](https://github.com/lhorie/mithril.js/pull/1598)
#### Bug fixes
- prevent infinite loop in non-existent default route - [#1579](https://github.com/lhorie/mithril.js/issues/1579)
- call correct lifecycle methods on children of recycled keyed vnodes - [#1609](https://github.com/lhorie/mithril.js/issues/1609)
---
### Migrating from `v0.2.x`

@@ -31,2 +45,3 @@

- [Accessing route params](#accessing-route-params)
- [Building/Parsing query strings](#buildingparsing-query-strings)
- [Preventing unmounting](#preventing-unmounting)

@@ -45,3 +60,3 @@ - [Run code on component removal](#run-code-on-component-removal)

In `v1.x`, `m.prop()` is now a more powerful stream micro-library, but it's no longer part of core. You can read about how to use the optional Streams module in [the documentation](streams.md).
In `v1.x`, `m.prop()` is now a more powerful stream micro-library, but it's no longer part of core. You can read about how to use the optional Streams module in [the documentation](stream.md).

@@ -464,2 +479,24 @@ ### `v0.2.x`

## Building/Parsing query strings
`v0.2.x` used methods hanging off of `m.route`, `m.route.buildQueryString()` and `m.route.parseQueryString()`. In `v1.x` these have been broken out and attached to the root `m`.
### `v0.2.x`
```javascript
var qs = m.route.buildQueryString({ a : 1 });
var obj = m.route.parseQueryString("a=1");
```
### `v1.x`
```javascript
var qs = m.buildQueryString({ a : 1 });
var obj = m.parseQueryString("a=1");
```
---
## Preventing unmounting

@@ -466,0 +503,0 @@

@@ -20,2 +20,3 @@ # Credits

- Pierre-Yves Gérardy, who consistently makes high quality contributions
- Gyandeep Singh, who contributed significant IE performance improvements

@@ -27,2 +28,1 @@ Other people who also deserve recognition:

- the countless people who have reported and fixed bugs, participated in discussions, and helped promote Mithril

@@ -84,3 +84,3 @@ # CSS

In plain CSS, all selectors live in the global scope and a prone to name collisions and specificity conflicts. CSS-in-JS aims to solve the issue of scoping in CSS, i.e. it groups related styles into non-global modules that are invisible to each other. CSS-in-JS is suitable for extremely large dev teams working on a single codebase, but it's not a good choice for most teams.
In plain CSS, all selectors live in the global scope and are prone to name collisions and specificity conflicts. CSS-in-JS aims to solve the issue of scoping in CSS, i.e. it groups related styles into non-global modules that are invisible to each other. CSS-in-JS is suitable for extremely large dev teams working on a single codebase, but it's not a good choice for most teams.

@@ -93,4 +93,4 @@ Nowadays there are [a lot of CSS-in-JS libraries with various degrees of robustness](https://github.com/MicheleBertoli/css-in-js).

Another common issue is lack of support for less basic CSS features such as `@keyframes` and @font-face.
Another common issue is lack of support for less basic CSS features such as `@keyframes` and `@font-face`.
If you are adamant on using a CSS-in-JS library, consider using [J2C](https://github.com/j2css/j2c).
If you are adamant about using a CSS-in-JS library, consider using [J2C](https://github.com/j2css/j2c), which works without configuration and implements `@keyframes` and `@font-face`.

@@ -25,3 +25,3 @@ # Framework comparison

In one sentence: because **Mithril is pragmatic**. The 10 minutes [guide](index.md) is a good example: that's how long it takes to learn components, XHR and routing - and that's just about the right amount of knowledge needed to build useful applications.
In one sentence: because **Mithril is pragmatic**. This [10 minute guide](index.md) is a good example: that's how long it takes to learn components, XHR and routing - and that's just about the right amount of knowledge needed to build useful applications.

@@ -28,0 +28,0 @@ Mithril is all about getting meaningful work done efficiently. Doing file uploads? [The docs show you how](request.md#file-uploads). Authentication? [Documented too](route.md#authentication). Exit animations? [You got it](animation.md). No extra libraries, no magic.

@@ -28,3 +28,3 @@ var fs = require("fs")

}
else if (!pathname.match(/tutorials|archive/)) {
else if (!pathname.match(/tutorials|archive|guides|methods/)) {
if (pathname.match(/\.md$/)) {

@@ -56,4 +56,4 @@ var outputFilename = pathname.replace(/\.md$/, ".html")

.replace(/\[body\]/, markedHtml)
.replace(/<h5 id="([^"]+?)">([^<]+?)<\/h5>/gim, function(match, id, text) { // fix anchors
return "<h5 id=\"" + text.toLowerCase().replace(/\.|\[|\]|&quot;|\//g, "") + "\">" + text + "</h5>"
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
return "<h" + n + " id=\"" + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|&quot;|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + "</h" + n + ">"
})

@@ -60,0 +60,0 @@ fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")

@@ -18,8 +18,2 @@ # Introduction

<style>
@keyframes grow {
from {transform:scaleX(0)}
to {transform:scaleX(100%)}
}
</style>
<div style="display:flex;margin:0 0 30px;">

@@ -63,9 +57,10 @@ <div style="width:50%;">

```markup
<body></body>
<script src="http://unpkg.com/mithril/mithril.js"></script>
<script>
var root = document.body
<body>
<script src="//unpkg.com/mithril/mithril.js"></script>
<script>
var root = document.body
// your code goes here!
</script>
// your code goes here!
</script>
</body>
```

@@ -234,3 +229,3 @@

First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `data` is the payload that we're sending to the endpoint and `useCredentials` means to enable cookies (a requirement for the REM API to work)
First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `data` is the payload that we're sending to the endpoint and `withCredentials` means to enable cookies (a requirement for the REM API to work)

@@ -242,5 +237,5 @@ ```javascript

method: "PUT",
url: "http://rem-rest-api.herokuapp.com/api/tutorial/1",
url: "//rem-rest-api.herokuapp.com/api/tutorial/1",
data: {count: count + 1},
useCredentials: true,
withCredentials: true,
})

@@ -247,0 +242,0 @@ .then(function(data) {

@@ -11,3 +11,3 @@ # Installation

```markup
<script src="http://unpkg.com/mithril/mithril.js"></script>
<script src="https://unpkg.com/mithril/mithril.js"></script>
```

@@ -223,3 +223,3 @@

<body>
<script src="http://cdn.rawgit.com/lhorie/mithril.js/rewrite/mithril.js"></script>
<script src="https://cdn.rawgit.com/lhorie/mithril.js/rewrite/mithril.js"></script>
<script src="index.js"></script>

@@ -226,0 +226,0 @@ </body>

@@ -6,3 +6,2 @@ # Keys

- [Debugging key related issues](#debugging-key-related-issues)
- [Avoid anti-patterns](#avoid-anti-patterns)

@@ -110,5 +109,7 @@ ---

}
// PREFER
users.map(function(u) {
return m("div", [
m(Button, {id: u.id}, u.name) // key should be here, not in component
m(Button, {key: u.id}, u.name) // key should be here, not in component
])

@@ -155,1 +156,27 @@ })

#### Avoid mixing keyed and non-keyed vnodes in the same array
An array of vnodes must have only keyed vnodes or non-keyed vnodes, but not both. If you need to mix them, create a nested array.
```javascript
// AVOID
m("div", [
m("div", "a"),
m("div", {key: 1}, "b"),
])
// PREFER
m("div", [
m("div", {key: 0}, "a"),
m("div", {key: 1}, "b"),
])
// PREFER
m("div", [
m("div", "a"),
[
m("div", {key: 1}, "b"),
]
])
```

@@ -91,3 +91,3 @@ #!/usr/bin/env node

var link = match.slice(2, -1)
var path = link.match(/[\w-]+\.md/)
var path = (link.match(/[\w-#]+\.md/) || [])[0]
if (link.match(/http/)) {

@@ -94,0 +94,0 @@ var u = url.parse(link)

@@ -388,3 +388,3 @@ # route(root, defaultRoute, routes)

In the example above, the layout merely consists of a `<div class="layout">` that contains the children passed to the component, but in a real life scenario it could be as complex as neeeded.
In the example above, the layout merely consists of a `<div class="layout">` that contains the children passed to the component, but in a real life scenario it could be as complex as needed.

@@ -391,0 +391,0 @@ One way to wrap the layout is to define an anonymous component in the routes map:

@@ -604,3 +604,3 @@ # Simple application

In the `/edit/:id` route, there's also a `vnode` argument that carries the route parameters into the `UserForm` component. So if the URL is `/edit/1`, then `vnode.attrs` in this case is `{id: 1}`, and this `m(UserForm, vnode.attrs)` is equivalent to `m(UserForm, {id: 1})`. The equivalent JSX code would be `<UserForm id={vnode.attrs} />`.
In the `/edit/:id` route, there's also a `vnode` argument that carries the route parameters into the `UserForm` component. So if the URL is `/edit/1`, then `vnode.attrs` in this case is `{id: 1}`, and this `m(UserForm, vnode.attrs)` is equivalent to `m(UserForm, {id: 1})`. The equivalent JSX code would be `<UserForm id={vnode.attrs.id} />`.

@@ -607,0 +607,0 @@ Refresh the page in the browser and now you'll see the global navigation on every page in the app.

@@ -14,7 +14,7 @@ # Virtual DOM nodes

A virtual DOM tree is a Javascript data structure that describes a DOM tree. It consists of nested virtual DOM nodes, also known *vnodes*.
A virtual DOM tree is a Javascript data structure that describes a DOM tree. It consists of nested virtual DOM nodes, also known as *vnodes*.
The first time a virtual DOM tree is rendered, it is used as a blueprint to create a DOM tree that matches its structure.
Typically, Virtual DOM trees are then recreated every render cycle, which normally occurs in response to event handlers or to data changes. Mithril *diffs* a vnode tree against its previous version and only modifies DOM elements in spots where there are changes.
Typically, virtual DOM trees are then recreated every render cycle, which normally occurs in response to event handlers or to data changes. Mithril *diffs* a vnode tree against its previous version and only modifies DOM elements in spots where there are changes.

@@ -27,3 +27,3 @@ It may seem wasteful to recreate vnodes so frequently, but as it turns out, modern Javascript engines can create hundreds of thousands of objects in less than a millisecond. On the other hand, modifying the DOM is several orders of magnitude more expensive than creating vnodes.

To illustrate why retained mode is so important, consider the DOM API and HTML. The DOM API is an [immediate mode](https://en.wikipedia.org/wiki/Immediate_mode_(computer_graphics)) rendering system and requires writing out exact instructions to assemble a DOM tree procedurally. The imperative nature of the DOM API means you have many opportunities to micro-optimize your code, but it also means that you have more chances for introducing bugs and more chances to make code harder to understand.
To illustrate why retained mode is so important, consider the DOM API and HTML. The DOM API is an [immediate mode](https://en.wikipedia.org/wiki/Immediate_mode_(computer_graphics)) rendering system and requires writing out exact instructions to assemble a DOM tree procedurally. The imperative nature of the DOM API means you have many opportunities to micro-optimize your code, but it also means that you have more chances of introducing bugs and more chances to make code harder to understand.

@@ -40,3 +40,3 @@ In contrast, HTML is a retained mode rendering system. With HTML, you can write a DOM tree in a far more natural and readable way, without worrying about forgetting to append a child to a parent, running into stack overflows when rendering extremely deep trees, etc.

Vnodes can be created via the [`m()`](hyperscript.md) hyperscript utility:
Vnodes are created via the [`m()`](hyperscript.md) hyperscript utility:

@@ -47,3 +47,3 @@ ```javascript

Vnodes can also consume [components](components.md):
Hyperscript can also consume [components](components.md):

@@ -77,4 +77,4 @@ ```javascript

`children` | `(Array|String|Number|Boolean)?` | In most vnode types, the `children` property is an array of vnodes. For text and trusted HTML vnodes, The `children` property is either a string, a number or a boolean.
`text` | `(String|Number|Boolean)?` | This is used instead of `children` if a vnode contains a text node as its only child. This is done for performance reasons. Component vnodes never use the `text` property even if they have a text node as its only child.
`dom` | `Element?` | Points to the element that corresponds to the vnode. This property is `undefined` in the `oninit` lifecycle method. In fragment and trusted HTML vnodes, `dom` points to the first element in the range.
`text` | `(String|Number|Boolean)?` | This is used instead of `children` if a vnode contains a text node as its only child. This is done for performance reasons. Component vnodes never use the `text` property even if they have a text node as their only child.
`dom` | `Element?` | Points to the element that corresponds to the vnode. This property is `undefined` in the `oninit` lifecycle method. In fragments and trusted HTML vnodes, `dom` points to the first element in the range.
`domSize` | `Number?` | This is only set in fragment and trusted HTML vnodes, and it's `undefined` in all other vnode types. It defines the number of DOM elements that the vnode represents (starting from the element referenced by the `dom` property).

@@ -118,2 +118,2 @@ `state` | `Object` | An object that is persisted between redraws. In component vnodes, `state` is a shallow clone of the component object.

It is possible to reuse vnodes to prevent a diff, but it's preferable to use the `onbeforeupdate` hook to make your intent clear to other developers (or your future self).
It is possible to reuse vnodes to prevent a diff, but it's preferable to use the `onbeforeupdate` hook to make your intent clear to other developers (or your future self).

@@ -358,7 +358,7 @@ new function() {

if (vnode != null) {
insertNode(parent, createNode(vnode, hooks, ns), nextSibling)
createNode(parent, vnode, hooks, ns, nextSibling)
}
}
}
function createNode(vnode, hooks, ns) {
function createNode(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag

@@ -368,17 +368,19 @@ if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)

switch (tag) {
case "#": return createText(vnode)
case "<": return createHTML(vnode)
case "[": return createFragment(vnode, hooks, ns)
default: return createElement(vnode, hooks, ns)
case "#": return createText(parent, vnode, nextSibling)
case "<": return createHTML(parent, vnode, nextSibling)
case "[": return createFragment(parent, vnode, hooks, ns, nextSibling)
default: return createElement(parent, vnode, hooks, ns, nextSibling)
}
}
else return createComponent(vnode, hooks, ns)
else return createComponent(parent, vnode, hooks, ns, nextSibling)
}
function createText(vnode) {
return vnode.dom = $doc.createTextNode(vnode.children)
function createText(parent, vnode, nextSibling) {
vnode.dom = $doc.createTextNode(vnode.children)
insertNode(parent, vnode.dom, nextSibling)
return vnode.dom
}
function createHTML(vnode) {
function createHTML(parent, vnode, nextSibling) {
var match1 = vnode.children.match(/^\s*?<(\w+)/im) || []
var parent = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match1[1]] || "div"
var temp = $doc.createElement(parent)
var parent1 = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match1[1]] || "div"
var temp = $doc.createElement(parent1)
temp.innerHTML = vnode.children

@@ -392,5 +394,6 @@ vnode.dom = temp.firstChild

}
insertNode(parent, fragment, nextSibling)
return fragment
}
function createFragment(vnode, hooks, ns) {
function createFragment(parent, vnode, hooks, ns, nextSibling) {
var fragment = $doc.createDocumentFragment()

@@ -403,5 +406,6 @@ if (vnode.children != null) {

vnode.domSize = fragment.childNodes.length
insertNode(parent, fragment, nextSibling)
return fragment
}
function createElement(vnode, hooks, ns) {
function createElement(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag

@@ -421,2 +425,3 @@ switch (vnode.tag) {

}
insertNode(parent, element, nextSibling)
if (vnode.attrs != null && vnode.attrs.contenteditable != null) {

@@ -438,3 +443,3 @@ setContentEditable(vnode)

}
function createComponent(vnode, hooks, ns) {
function createComponent(parent, vnode, hooks, ns, nextSibling) {
vnode.state = Object.create(vnode.tag)

@@ -449,5 +454,6 @@ var view = vnode.tag.view

if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
var element = createNode(vnode.instance, hooks, ns)
var element = createNode(parent, vnode.instance, hooks, ns, nextSibling)
vnode.dom = vnode.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
insertNode(parent, element, nextSibling)
return element

@@ -461,3 +467,3 @@ }

//update
function updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {
function updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {
if (old === vnodes || old == null && vnodes == null) return

@@ -478,3 +484,3 @@ else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined)

if (old[i] === vnodes[i]) continue
else if (old[i] == null && vnodes[i] != null) insertNode(parent, createNode(vnodes[i], hooks, ns), getNextSibling(old, i + 1, nextSibling))
else if (old[i] == null && vnodes[i] != null) createNode(parent, vnodes[i], hooks, ns, getNextSibling(old, i + 1, nextSibling))
else if (vnodes[i] == null) removeNodes(old, i, i + 1, vnodes)

@@ -486,4 +492,5 @@ else updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), false, ns)

}
var recycling = isRecyclable(old, vnodes)
recycling = recycling || isRecyclable(old, vnodes)
if (recycling) old = old.concat(old.pool)
var oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map

@@ -536,4 +543,3 @@ while (oldEnd >= oldStart && end >= start) {

else {
var dom = createNode(v, hooks, undefined)
insertNode(parent, dom, nextSibling)
var dom = createNode(parent, v, hooks, undefined, nextSibling)
nextSibling = dom

@@ -563,4 +569,4 @@ }

case "<": updateHTML(parent, old, vnode, nextSibling); break
case "[": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break
default: updateElement(old, vnode, hooks, ns)
case "[": updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns); break
default: updateElement(old, vnode, recycling, hooks, ns)
}

@@ -572,3 +578,3 @@ }

removeNode(old, null)
insertNode(parent, createNode(vnode, hooks, ns), nextSibling)
createNode(parent, vnode, hooks, ns, nextSibling)
}

@@ -585,8 +591,8 @@ }

toFragment(old)
insertNode(parent, createHTML(vnode), nextSibling)
createHTML(parent, vnode, nextSibling)
}
else vnode.dom = old.dom, vnode.domSize = old.domSize
}
function updateFragment(parent, old, vnode, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns)
function updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, recycling, hooks, nextSibling, ns)
var domSize = 0, children = vnode.children

@@ -605,3 +611,3 @@ vnode.dom = null

}
function updateElement(old, vnode, hooks, ns) {
function updateElement(old, vnode, recycling, hooks, ns) {
var element = vnode.dom = old.dom

@@ -629,3 +635,3 @@ switch (vnode.tag) {

if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
updateNodes(element, old.children, vnode.children, hooks, null, ns)
updateNodes(element, old.children, vnode.children, recycling, hooks, null, ns)
}

@@ -637,3 +643,3 @@ }

if (vnode.instance != null) {
if (old.instance == null) insertNode(parent, createNode(vnode.instance, hooks, ns), nextSibling)
if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)

@@ -906,3 +912,3 @@ vnode.dom = vnode.instance.dom

if (!Array.isArray(vnodes)) vnodes = [vnodes]
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), hooks, null, undefined)
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, undefined)
dom.vnodes = vnodes

@@ -939,3 +945,2 @@ for (var i = 0; i < hooks.length; i++) hooks[i]()

})
var callbacks = []

@@ -1078,3 +1083,2 @@ function subscribe(key1, callback) {

var pathname = parsePath(path, params, params)
var state = $window.history.state

@@ -1100,3 +1104,2 @@ if (state != null) {

}
if (supportsPushState) $window.onpopstate = debounceAsync(resolveRoute)

@@ -1106,3 +1109,2 @@ else if (router.prefix.charAt(0) === "#") $window.onhashchange = resolveRoute

}
return router

@@ -1119,4 +1121,5 @@ }

}
var bail = function() {
routeService.setPath(defaultRoute, null, {replace: true})
var bail = function(path) {
if (path !== defaultRoute) routeService.setPath(defaultRoute, null, {replace: true})
else throw new Error("Could not resolve default route " + defaultRoute)
}

@@ -1179,3 +1182,3 @@ routeService.defineRoutes(routes, function(payload, params, path) {

m.buildQueryString = buildQueryString
m.version = "1.0.0"
m.version = "1.0.1"
m.vnode = Vnode

@@ -1182,0 +1185,0 @@ if (typeof module !== "undefined") module["exports"] = m

@@ -1,42 +0,42 @@

new function(){function x(a,c,k,d,h,m){return{tag:a,key:c,attrs:k,children:d,text:h,dom:m,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function B(a){if(null==a||"string"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===G[a]){for(var c,k,d=[],h={};c=N.exec(a);){var m=c[1],l=c[2];""===m&&""!==l?k=l:"#"===m?h.id=l:"."===m?d.push(l):"["===c[3][0]&&((m=c[6])&&(m=m.replace(/\\(["'])/g,"$1").replace(/\\\\/g,
"\\")),"class"===c[4]?d.push(m):h[c[4]]=m||!0)}0<d.length&&(h.className=d.join(" "));G[a]=function(a,c){var m=!1,b,r,d=a.className||a["class"],p;for(p in h)a[p]=h[p];void 0!==d&&(void 0!==a["class"]&&(a["class"]=void 0,a.className=d),void 0!==h.className&&(a.className=h.className+" "+d));for(p in a)if("key"!==p){m=!0;break}Array.isArray(c)&&1==c.length&&null!=c[0]&&"#"===c[0].tag?r=c[0].children:b=c;return x(k||"div",a.key,m?a:void 0,b,r,void 0)}}var p;null==arguments[1]||"object"===typeof arguments[1]&&
void 0===arguments[1].tag&&!Array.isArray(arguments[1])?(p=arguments[1],d=2):d=1;if(arguments.length===d+1)c=Array.isArray(arguments[d])?arguments[d]:[arguments[d]];else for(c=[];d<arguments.length;d++)c.push(arguments[d]);return"string"===typeof a?G[a](p||{},x.normalizeChildren(c)):x(a,p&&p.key,p||{},x.normalizeChildren(c),void 0,void 0)}function O(a){var c=0,k=null,d="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var h=Date.now();0===c||16<=h-c?(c=h,
a()):null===k&&(k=d(function(){k=null;a();c=Date.now()},16-(h-c)))}}x.normalize=function(a){return Array.isArray(a)?x("[",void 0,void 0,x.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?x("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};x.normalizeChildren=function(a){for(var c=0;c<a.length;c++)a[c]=x.normalize(a[c]);return a};var N=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,G={};B.trust=function(a){null==a&&(a="");return x("<",void 0,void 0,a,void 0,
void 0)};B.fragment=function(a,c){return x("[",a.key,a,x.normalizeChildren(c),void 0,void 0)};var w=function(a){function c(a,b){return function v(c){var l;try{if(!b||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(l=c.then))q(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",c);for(var d=0;d<a.length;d++)a[d](c);h.length=0;m.length=0;r.state=b;r.retry=function(){v(c)}});else{if(c===d)throw new TypeError("Promise can't be resolved w/ itself");
k(l.bind(c))}}catch(P){p(P)}}}function k(a){function b(b){return function(a){0<c++||b(a)}}var c=0,d=b(p);try{a(b(l),d)}catch(D){d(D)}}if(!(this instanceof w))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var d=this,h=[],m=[],l=c(h,!0),p=c(m,!1),r=d._instance={resolvers:h,rejectors:m},q="function"===typeof setImmediate?setImmediate:setTimeout;k(a)};w.prototype.then=function(a,c){function k(a,c,k,l){c.push(function(b){if("function"!==
typeof a)k(b);else try{h(a(b))}catch(A){m&&m(A)}});"function"===typeof d.retry&&l===d.state&&d.retry()}var d=this._instance,h,m,l=new w(function(a,c){h=a;m=c});k(a,d.resolvers,h,!0);k(c,d.rejectors,m,!1);return l};w.prototype["catch"]=function(a){return this.then(null,a)};w.resolve=function(a){return a instanceof w?a:new w(function(c){c(a)})};w.reject=function(a){return new w(function(c,k){k(a)})};w.all=function(a){return new w(function(c,k){var d=a.length,h=0,m=[];if(0===a.length)c([]);else for(var l=
0;l<a.length;l++)(function(l){function r(a){h++;m[l]=a;h===d&&c(m)}null==a[l]||"object"!==typeof a[l]&&"function"!==typeof a[l]||"function"!==typeof a[l].then?r(a[l]):a[l].then(r,k)})(l)})};w.race=function(a){return new w(function(c,k){for(var d=0;d<a.length;d++)a[d].then(c,k)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=w),w=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=w),w=global.Promise);var E=function(a){function c(a,
d){if(Array.isArray(d))for(var h=0;h<d.length;h++)c(a+"["+h+"]",d[h]);else if("[object Object]"===Object.prototype.toString.call(d))for(h in d)c(a+"["+h+"]",d[h]);else k.push(encodeURIComponent(a)+(null!=d&&""!==d?"="+encodeURIComponent(d):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var k=[],d;for(d in a)c(d,a[d]);return k.join("&")},I=function(a,c){function k(){function b(){0===--a&&"function"===typeof u&&u()}var a=0;return function D(c){var d=c.then;c.then=function(){a++;
var h=d.apply(c,arguments);h.then(b,function(c){b();if(0===a)throw c;});return D(h)};return c}}function d(b,a){if("string"===typeof b){var c=b;b=a||{};null==b.url&&(b.url=c)}return b}function h(b,a){if(null==a)return b;for(var c=b.match(/:[^\/]+/gi)||[],d=0;d<c.length;d++){var h=c[d].slice(1);null!=a[h]&&(b=b.replace(c[d],a[h]))}return b}function m(b,a){var c=E(a);if(""!==c){var d=0>b.indexOf("?")?"?":"&";b+=d+c}return b}function l(a){try{return""!==a?JSON.parse(a):null}catch(A){throw Error(a);}}
function p(a){return a.responseText}function r(a,c){if("function"===typeof a)if(Array.isArray(c))for(var b=0;b<c.length;b++)c[b]=new a(c[b]);else return new a(c);return c}var q=0,u;return{request:function(b,u){var q=k();b=d(b,u);var A=new c(function(c,d){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var k="boolean"===typeof b.useBody?b.useBody:"GET"!==b.method&&"TRACE"!==b.method;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?
function(a){return a}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=l);"function"!==typeof b.extract&&(b.extract=p);b.url=h(b.url,b.data);k?b.data=b.serialize(b.data):b.url=m(b.url,b.data);var n=new a.XMLHttpRequest;n.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize===JSON.stringify&&k&&n.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize===
l&&n.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(n.withCredentials=b.withCredentials);for(var u in b.headers)({}).hasOwnProperty.call(b.headers,u)&&n.setRequestHeader(u,b.headers[u]);"function"===typeof b.config&&(n=b.config(n,b)||n);n.onreadystatechange=function(){if(n.status&&4===n.readyState)try{var a=b.extract!==p?b.extract(n,b):b.deserialize(b.extract(n,b));if(200<=n.status&&300>n.status||304===n.status)c(r(b.type,a));else{var g=Error(n.responseText),e;for(e in a)g[e]=
a[e];d(g)}}catch(f){d(f)}};k&&null!=b.data?n.send(b.data):n.send()});return!0===b.background?A:q(A)},jsonp:function(b,l){var p=k();b=d(b,l);var u=new c(function(c,d){var k=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+q++,l=a.document.createElement("script");a[k]=function(d){l.parentNode.removeChild(l);c(r(b.type,d));delete a[k]};l.onerror=function(){l.parentNode.removeChild(l);d(Error("JSONP request failed"));delete a[k]};null==b.data&&(b.data={});b.url=h(b.url,b.data);b.data[b.callbackKey||
"callback"]=k;l.src=m(b.url,b.data);a.document.documentElement.appendChild(l)});return!0===b.background?u:p(u)},setCompletionCallback:function(a){u=a}}}(window,w),M=function(a){function c(g,e,a,b,c,d,h){for(;a<b;a++){var f=e[a];null!=f&&r(g,k(f,c,h),d)}}function k(g,e,a){var b=g.tag;null!=g.attrs&&B(g.attrs,g,e);if("string"===typeof b)switch(b){case "#":return g.dom=n.createTextNode(g.children);case "<":return d(g);case "[":var f=n.createDocumentFragment();null!=g.children&&(b=g.children,c(f,b,0,
b.length,e,null,a));g.dom=f.firstChild;g.domSize=f.childNodes.length;return f;default:var h=g.tag;switch(g.tag){case "svg":a="http://www.w3.org/2000/svg";break;case "math":a="http://www.w3.org/1998/Math/MathML"}var l=(b=g.attrs)&&b.is,h=a?l?n.createElementNS(a,h,{is:l}):n.createElementNS(a,h):l?n.createElement(h,{is:l}):n.createElement(h);g.dom=h;if(null!=b)for(f in l=a,b)v(g,f,null,b[f],l);null!=g.attrs&&null!=g.attrs.contenteditable?q(g):(null!=g.text&&(""!==g.text?h.textContent=g.text:g.children=
[x("#",void 0,void 0,g.text,void 0,void 0)]),null!=g.children&&(f=g.children,c(h,f,0,f.length,e,null,a),e=g.attrs,"select"===g.tag&&null!=e&&("value"in e&&v(g,"value",null,e.value,void 0),"selectedIndex"in e&&v(g,"selectedIndex",null,e.selectedIndex,void 0))));return h}else{g.state=Object.create(g.tag);f=g.tag.view;if(null!=f.reentrantLock)g=L;else if(f.reentrantLock=!0,B(g.tag,g,e),g.instance=x.normalize(f.call(g.state,g)),f.reentrantLock=null,null!=g.instance){if(g.instance===g)throw Error("A view cannot return the vnode it received as arguments");
e=k(g.instance,e,a);g.dom=g.instance.dom;g.domSize=null!=g.dom?g.instance.domSize:0;g=e}else g.domSize=0,g=L;return g}}function d(g){var e={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(g.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",e=n.createElement(e);e.innerHTML=g.children;g.dom=e.firstChild;g.domSize=e.childNodes.length;g=n.createDocumentFragment();for(var a;a=e.firstChild;)g.appendChild(a);return g}function h(g,e,a,b,
d,h){if(e!==a&&(null!=e||null!=a))if(null==e)c(g,a,0,a.length,b,d,void 0);else if(null==a)u(e,0,e.length,a);else{if(e.length===a.length){for(var f=!1,t=0;t<a.length;t++)if(null!=a[t]&&null!=e[t]){f=null==a[t].key&&null==e[t].key;break}if(f){for(t=0;t<e.length;t++)e[t]!==a[t]&&(null==e[t]&&null!=a[t]?r(g,k(a[t],b,h),p(e,t+1,d)):null==a[t]?u(e,t,t+1,a):m(g,e[t],a[t],b,p(e,t+1,d),!1,h));return}}a:{if(null!=e.pool&&Math.abs(e.pool.length-a.length)<=Math.abs(e.length-a.length)&&(f=a[0]&&a[0].children&&
a[0].children.length||0,Math.abs((e.pool[0]&&e.pool[0].children&&e.pool[0].children.length||0)-f)<=Math.abs((e[0]&&e[0].children&&e[0].children.length||0)-f))){f=!0;break a}f=!1}f&&(e=e.concat(e.pool));for(var n=t=0,q=e.length-1,A=a.length-1,z;q>=t&&A>=n;){var y=e[t],v=a[n];if(y!==v||f)if(null==y)t++;else if(null==v)n++;else if(y.key===v.key)t++,n++,m(g,y,v,b,p(e,t,d),f,h),f&&y.tag===v.tag&&r(g,l(y),d);else if(y=e[q],y!==v||f)if(null==y)q--;else if(null==v)n++;else if(y.key===v.key)m(g,y,v,b,p(e,
q+1,d),f,h),(f||n<A)&&r(g,l(y),p(e,t,d)),q--,n++;else break;else q--,n++;else t++,n++}for(;q>=t&&A>=n;){y=e[q];v=a[A];if(y!==v||f)if(null==y)q--;else{if(null!=v)if(y.key===v.key)m(g,y,v,b,p(e,q+1,d),f,h),f&&y.tag===v.tag&&r(g,l(y),d),null!=y.dom&&(d=y.dom),q--;else{if(!z){z=e;var y=q,C={},x;for(x=0;x<y;x++){var w=z[x];null!=w&&(w=w.key,null!=w&&(C[w]=x))}z=C}null!=v&&(y=z[v.key],null!=y?(C=e[y],m(g,C,v,b,p(e,q+1,d),f,h),r(g,l(C),d),e[y].skip=!0,null!=C.dom&&(d=C.dom)):(v=k(v,b,void 0),r(g,v,d),d=
v))}A--}else q--,A--;if(A<n)break}c(g,a,n,A+1,b,d,h);u(e,t,q+1,a)}}function m(a,e,f,c,n,u,p){var g=e.tag;if(g===f.tag){f.state=e.state;f.events=e.events;var t;var A;null!=f.attrs&&"function"===typeof f.attrs.onbeforeupdate&&(t=f.attrs.onbeforeupdate.call(f.state,f,e));"string"!==typeof f.tag&&"function"===typeof f.tag.onbeforeupdate&&(A=f.tag.onbeforeupdate.call(f.state,f,e));void 0===t&&void 0===A||t||A?t=!1:(f.dom=e.dom,f.domSize=e.domSize,f.instance=e.instance,t=!0);if(!t)if(null!=f.attrs&&K(f.attrs,
f,c,u),"string"===typeof g)switch(g){case "#":e.children.toString()!==f.children.toString()&&(e.dom.nodeValue=f.children);f.dom=e.dom;break;case "<":e.children!==f.children?(l(e),r(a,d(f),n)):(f.dom=e.dom,f.domSize=e.domSize);break;case "[":h(a,e.children,f.children,c,n,p);e=0;c=f.children;f.dom=null;if(null!=c){for(var z=0;z<c.length;z++)a=c[z],null!=a&&null!=a.dom&&(null==f.dom&&(f.dom=a.dom),e+=a.domSize||1);1!==e&&(f.domSize=e)}break;default:a=p;n=f.dom=e.dom;switch(f.tag){case "svg":a="http://www.w3.org/2000/svg";
break;case "math":a="http://www.w3.org/1998/Math/MathML"}"textarea"===f.tag&&(null==f.attrs&&(f.attrs={}),null!=f.text&&(f.attrs.value=f.text,f.text=void 0));u=e.attrs;p=f.attrs;g=a;if(null!=p)for(z in p)v(f,z,u&&u[z],p[z],g);if(null!=u)for(z in u)null!=p&&z in p||("className"===z&&(z="class"),"o"!==z[0]||"n"!==z[1]||D(z)?"key"!==z&&f.dom.removeAttribute(z):w(f,z,void 0));null!=f.attrs&&null!=f.attrs.contenteditable?q(f):null!=e.text&&null!=f.text&&""!==f.text?e.text.toString()!==f.text.toString()&&
(e.dom.firstChild.nodeValue=f.text):(null!=e.text&&(e.children=[x("#",void 0,void 0,e.text,void 0,e.dom.firstChild)]),null!=f.text&&(f.children=[x("#",void 0,void 0,f.text,void 0,void 0)]),h(n,e.children,f.children,c,null,a))}else f.instance=x.normalize(f.tag.view.call(f.state,f)),K(f.tag,f,c,u),null!=f.instance?(null==e.instance?r(a,k(f.instance,c,p),n):m(a,e.instance,f.instance,c,n,u,p),f.dom=f.instance.dom,f.domSize=f.instance.domSize):null!=e.instance?(b(e.instance,null),f.dom=void 0,f.domSize=
0):(f.dom=e.dom,f.domSize=e.domSize)}else b(e,null),r(a,k(f,c,p),n)}function l(a){var g=a.domSize;if(null!=g||null==a.dom){var b=n.createDocumentFragment();if(0<g){for(a=a.dom;--g;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function p(a,e,b){for(;e<a.length;e++)if(null!=a[e]&&null!=a[e].dom)return a[e].dom;return b}function r(a,e,b){b&&b.parentNode?a.insertBefore(e,b):a.appendChild(e)}function q(a){var e=a.children;if(null!=e&&1===e.length&&"<"===e[0].tag)e=
e[0].children,a.dom.innerHTML!==e&&(a.dom.innerHTML=e);else if(null!=a.text||null!=e&&0!==e.length)throw Error("Child node of a contenteditable must be trusted");}function u(a,e,f,c){for(;e<f;e++){var g=a[e];null!=g&&(g.skip?g.skip=!1:b(g,c))}}function b(a,e){function b(){if(++c===g&&(A(a),a.dom)){var b=a.domSize||1;if(1<b)for(var f=a.dom;--b;){var d=f.nextSibling,h=d.parentNode;null!=h&&h.removeChild(d)}b=a.dom;f=b.parentNode;null!=f&&f.removeChild(b);if(b=null!=e&&null==a.domSize)b=a.attrs,b=!(null!=
b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(e.pool?e.pool.push(a):e.pool=[a])}}var g=1,c=0;if(a.attrs&&a.attrs.onbeforeremove){var d=a.attrs.onbeforeremove.call(a.state,a);null!=d&&"function"===typeof d.then&&(g++,d.then(b,b))}"string"!==typeof a.tag&&a.tag.onbeforeremove&&(d=a.tag.onbeforeremove.call(a.state,a),null!=d&&"function"===typeof d.then&&(g++,d.then(b,b)));b()}function A(a){a.attrs&&a.attrs.onremove&&a.attrs.onremove.call(a.state,a);"string"!==
typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)A(a.instance);else if(a=a.children,Array.isArray(a))for(var b=0;b<a.length;b++){var g=a[b];null!=g&&A(g)}}function v(a,b,c,d,h){var e=a.dom;if("key"!==b&&"is"!==b&&(c!==d||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===n.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&!D(b)){var g=b.indexOf(":");if(-1<g&&"xlink"===b.substr(0,g))e.setAttributeNS("http://www.w3.org/1999/xlink",b.slice(g+
1),d);else if("o"===b[0]&&"n"===b[1]&&"function"===typeof d)w(a,b,d);else if("style"===b)if(a=c,a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else{"string"===typeof a&&(e.style.cssText="");for(var f in d)e.style[f]=d[f];if(null!=a&&"string"!==typeof a)for(f in a)f in d||(e.style[f]="")}else b in e&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===h&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&"value"===
b&&a.dom.value===d&&a.dom===n.activeElement||"select"===a.tag&&"value"===b&&a.dom.value===d&&a.dom===n.activeElement||"option"===a.tag&&"value"===b&&a.dom.value===d||(e[b]=d):"boolean"===typeof d?d?e.setAttribute(b,""):e.removeAttribute(b):e.setAttribute("className"===b?"class":b,d)}}function D(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function w(a,b,d){var e=a.dom,c="function"!==typeof H?d:function(a){var b=d.call(e,a);H.call(e,
a);return b};if(b in e)e[b]="function"===typeof d?c:null;else{var f=b.slice(2);void 0===a.events&&(a.events={});a.events[b]!==c&&(null!=a.events[b]&&e.removeEventListener(f,a.events[b],!1),"function"===typeof d&&(a.events[b]=c,e.addEventListener(f,a.events[b],!1)))}}function B(a,b,d){"function"===typeof a.oninit&&a.oninit.call(b.state,b);"function"===typeof a.oncreate&&d.push(a.oncreate.bind(b.state,b))}function K(a,b,d,c){c?B(a,b,d):"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,
b))}var n=a.document,L=n.createDocumentFragment(),H;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var d=[],e=n.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);h(a,a.vnodes,x.normalizeChildren(b),d,null,void 0);a.vnodes=b;for(var c=0;c<d.length;c++)d[c]();n.activeElement!==e&&e.focus()},setEventCallback:function(a){return H=a}}},F=function(a){function c(a){a=d.indexOf(a);-1<a&&d.splice(a,
2)}function k(){for(var a=1;a<d.length;a+=2)d[a]()}a=M(a);a.setEventCallback(function(a){!1!==a.redraw&&k()});var d=[];return{subscribe:function(a,k){c(a);d.push(a,O(k))},unsubscribe:c,redraw:k,render:a.render}}(window);I.setCompletionCallback(F.redraw);B.mount=function(a){return function(c,k){if(null===k)a.render(c,[]),a.unsubscribe(c);else{if(null==k.view)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(c,function(){a.render(c,x(k))});a.redraw()}}}(F);var Q=
w,J=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var c={},k={},d=0;d<a.length;d++){var h=a[d].split("="),m=decodeURIComponent(h[0]),h=2===h.length?decodeURIComponent(h[1]):"";"true"===h?h=!0:"false"===h&&(h=!1);var l=m.split(/\]\[?|\[/),p=c;-1<m.indexOf("[")&&l.pop();for(var r=0;r<l.length;r++){var m=l[r],q=l[r+1],q=""==q||!isNaN(parseInt(q,10)),u=r===l.length-1;""===m&&(m=l.slice(0,r).join(),null==k[m]&&(k[m]=0),m=k[m]++);null==p[m]&&(p[m]=u?h:q?[]:
{});p=p[m]}}return c},R=function(a){function c(d){var c=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==c[0]&&(c="/"+c);return c}function k(a){return function(){null==l&&(l=m(function(){l=null;a()}))}}function d(a,d,c){var b=a.indexOf("?"),h=a.indexOf("#"),k=-1<b?b:-1<h?h:a.length;if(-1<b){var b=J(a.slice(b+1,-1<h?h:a.length)),l;for(l in b)d[l]=b[l]}if(-1<h)for(l in d=J(a.slice(h+1)),d)c[l]=d[l];return a.slice(0,k)}var h="function"===typeof a.history.pushState,
m="function"===typeof setImmediate?setImmediate:setTimeout,l,p={prefix:"#!",getPath:function(){switch(p.prefix.charAt(0)){case "#":return c("hash").slice(p.prefix.length);case "?":return c("search").slice(p.prefix.length)+c("hash");default:return c("pathname").slice(p.prefix.length)+c("search")+c("hash")}},setPath:function(c,l,k){var b={},m={};c=d(c,b,m);if(null!=l){for(var v in l)b[v]=l[v];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return l[c]})}(v=E(b))&&(c+="?"+v);(m=E(m))&&(c+="#"+m);
h?(m=k?k.state:null,v=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(m,v,p.prefix+c):a.history.pushState(m,v,p.prefix+c)):a.location.href=p.prefix+c},defineRoutes:function(c,l,m){function b(){var b=p.getPath(),h={},k=d(b,h,h),u=a.history.state;if(null!=u)for(var q in u)h[q]=u[q];for(var r in c)if(u=new RegExp("^"+r.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),u.test(k)){k.replace(u,function(){for(var a=r.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,
1,-2),k=0;k<a.length;k++)h[a[k].replace(/:|\./g,"")]=decodeURIComponent(d[k]);l(c[r],h,b,r)});return}m(b,h)}h?a.onpopstate=k(b):"#"===p.prefix.charAt(0)&&(a.onhashchange=b);b()}};return p};B.route=function(a,c){var k=R(a),d=function(a){return a},h,m,l,p,r,q=function(a,b,q){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var u=function(){null!=h&&c.render(a,h(x(m,l.key,l)))},w=function(){k.setPath(b,null,{replace:!0})};k.defineRoutes(q,function(a,b,c){var k=
r=function(a,n){k===r&&(m=null!=n&&"function"===typeof n.view?n:"div",l=b,p=c,r=null,h=(a.render||d).bind(a),u())};a.view?k({},a):a.onmatch?Q.resolve(a.onmatch(b,c)).then(function(b){k(a,b)},w):k(a,"div")},w);c.subscribe(a,u)};q.set=function(a,b,c){null!=r&&(c={replace:!0});r=null;k.setPath(a,b,c)};q.get=function(){return p};q.prefix=function(a){k.prefix=a};q.link=function(a){a.dom.setAttribute("href",k.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||
(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(k.prefix)&&(a=a.slice(k.prefix.length)),q.set(a,void 0,void 0))}};q.param=function(a){return"undefined"!==typeof l&&"undefined"!==typeof a?l[a]:l};return q}(window,F);B.withAttr=function(a,c,k){return function(d){c.call(k||this,a in d.currentTarget?d.currentTarget[a]:d.currentTarget.getAttribute(a))}};var S=M(window);B.render=S.render;B.redraw=F.redraw;B.request=I.request;B.jsonp=I.jsonp;B.parseQueryString=J;B.buildQueryString=
E;B.version="1.0.0";B.vnode=x;"undefined"!==typeof module?module.exports=B:window.m=B};
new function(){function w(a,d,h,f,g,l){return{tag:a,key:d,attrs:h,children:f,text:g,dom:l,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function z(a){if(null==a||"string"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===G[a]){for(var d,h,f=[],g={};d=N.exec(a);){var l=d[1],k=d[2];""===l&&""!==k?h=k:"#"===l?g.id=k:"."===l?f.push(k):"["===d[3][0]&&((l=d[6])&&(l=l.replace(/\\(["'])/g,"$1").replace(/\\\\/g,
"\\")),"class"===d[4]?f.push(l):g[d[4]]=l||!0)}0<f.length&&(g.className=f.join(" "));G[a]=function(a,d){var l=!1,b,f,p=a.className||a["class"],m;for(m in g)a[m]=g[m];void 0!==p&&(void 0!==a["class"]&&(a["class"]=void 0,a.className=p),void 0!==g.className&&(a.className=g.className+" "+p));for(m in a)if("key"!==m){l=!0;break}Array.isArray(d)&&1==d.length&&null!=d[0]&&"#"===d[0].tag?f=d[0].children:b=d;return w(h||"div",a.key,l?a:void 0,b,f,void 0)}}var m;null==arguments[1]||"object"===typeof arguments[1]&&
void 0===arguments[1].tag&&!Array.isArray(arguments[1])?(m=arguments[1],f=2):f=1;if(arguments.length===f+1)d=Array.isArray(arguments[f])?arguments[f]:[arguments[f]];else for(d=[];f<arguments.length;f++)d.push(arguments[f]);return"string"===typeof a?G[a](m||{},w.normalizeChildren(d)):w(a,m&&m.key,m||{},w.normalizeChildren(d),void 0,void 0)}function O(a){var d=0,h=null,f="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var g=Date.now();0===d||16<=g-d?(d=g,
a()):null===h&&(h=f(function(){h=null;a();d=Date.now()},16-(g-d)))}}w.normalize=function(a){return Array.isArray(a)?w("[",void 0,void 0,w.normalizeChildren(a),void 0,void 0):null!=a&&"object"!==typeof a?w("#",void 0,void 0,!1===a?"":a,void 0,void 0):a};w.normalizeChildren=function(a){for(var d=0;d<a.length;d++)a[d]=w.normalize(a[d]);return a};var N=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g,G={};z.trust=function(a){null==a&&(a="");return w("<",void 0,void 0,a,void 0,
void 0)};z.fragment=function(a,d){return w("[",a.key,a,w.normalizeChildren(d),void 0,void 0)};var v=function(a){function d(a,b){return function y(d){var k;try{if(!b||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(k=d.then))u(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",d);for(var f=0;f<a.length;f++)a[f](d);g.length=0;l.length=0;p.state=b;p.retry=function(){y(d)}});else{if(d===f)throw new TypeError("Promise can't be resolved w/ itself");
h(k.bind(d))}}catch(P){m(P)}}}function h(a){function b(b){return function(a){0<d++||b(a)}}var d=0,f=b(m);try{a(b(k),f)}catch(D){f(D)}}if(!(this instanceof v))throw Error("Promise must be called with `new`");if("function"!==typeof a)throw new TypeError("executor must be a function");var f=this,g=[],l=[],k=d(g,!0),m=d(l,!1),p=f._instance={resolvers:g,rejectors:l},u="function"===typeof setImmediate?setImmediate:setTimeout;h(a)};v.prototype.then=function(a,d){function h(a,d,h,k){d.push(function(b){if("function"!==
typeof a)h(b);else try{g(a(b))}catch(B){l&&l(B)}});"function"===typeof f.retry&&k===f.state&&f.retry()}var f=this._instance,g,l,k=new v(function(a,d){g=a;l=d});h(a,f.resolvers,g,!0);h(d,f.rejectors,l,!1);return k};v.prototype["catch"]=function(a){return this.then(null,a)};v.resolve=function(a){return a instanceof v?a:new v(function(d){d(a)})};v.reject=function(a){return new v(function(d,h){h(a)})};v.all=function(a){return new v(function(d,h){var f=a.length,g=0,l=[];if(0===a.length)d([]);else for(var k=
0;k<a.length;k++)(function(k){function p(a){g++;l[k]=a;g===f&&d(l)}null==a[k]||"object"!==typeof a[k]&&"function"!==typeof a[k]||"function"!==typeof a[k].then?p(a[k]):a[k].then(p,h)})(k)})};v.race=function(a){return new v(function(d,h){for(var f=0;f<a.length;f++)a[f].then(d,h)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=v),v=window.Promise):"undefined"!==typeof global&&("undefined"===typeof global.Promise&&(global.Promise=v),v=global.Promise);var E=function(a){function d(a,
f){if(Array.isArray(f))for(var g=0;g<f.length;g++)d(a+"["+g+"]",f[g]);else if("[object Object]"===Object.prototype.toString.call(f))for(g in f)d(a+"["+g+"]",f[g]);else h.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var h=[],f;for(f in a)d(f,a[f]);return h.join("&")},I=function(a,d){function h(){function b(){0===--a&&"function"===typeof x&&x()}var a=0;return function D(d){var f=d.then;d.then=function(){a++;
var g=f.apply(d,arguments);g.then(b,function(d){b();if(0===a)throw d;});return D(g)};return d}}function f(b,a){if("string"===typeof b){var d=b;b=a||{};null==b.url&&(b.url=d)}return b}function g(b,a){if(null==a)return b;for(var d=b.match(/:[^\/]+/gi)||[],f=0;f<d.length;f++){var g=d[f].slice(1);null!=a[g]&&(b=b.replace(d[f],a[g]))}return b}function l(b,a){var d=E(a);if(""!==d){var f=0>b.indexOf("?")?"?":"&";b+=f+d}return b}function k(b){try{return""!==b?JSON.parse(b):null}catch(B){throw Error(b);}}
function m(b){return b.responseText}function p(b,a){if("function"===typeof b)if(Array.isArray(a))for(var d=0;d<a.length;d++)a[d]=new b(a[d]);else return new b(a);return a}var u=0,x;return{request:function(b,x){var u=h();b=f(b,x);var B=new d(function(d,f){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var h="boolean"===typeof b.useBody?b.useBody:"GET"!==b.method&&"TRACE"!==b.method;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?
function(a){return a}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=k);"function"!==typeof b.extract&&(b.extract=m);b.url=g(b.url,b.data);h?b.data=b.serialize(b.data):b.url=l(b.url,b.data);var q=new a.XMLHttpRequest;q.open(b.method,b.url,"boolean"===typeof b.async?b.async:!0,"string"===typeof b.user?b.user:void 0,"string"===typeof b.password?b.password:void 0);b.serialize===JSON.stringify&&h&&q.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize===
k&&q.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(q.withCredentials=b.withCredentials);for(var x in b.headers)({}).hasOwnProperty.call(b.headers,x)&&q.setRequestHeader(x,b.headers[x]);"function"===typeof b.config&&(q=b.config(q,b)||q);q.onreadystatechange=function(){if(q.status&&4===q.readyState)try{var a=b.extract!==m?b.extract(q,b):b.deserialize(b.extract(q,b));if(200<=q.status&&300>q.status||304===q.status)d(p(b.type,a));else{var n=Error(q.responseText),c;for(c in a)n[c]=
a[c];f(n)}}catch(e){f(e)}};h&&null!=b.data?q.send(b.data):q.send()});return!0===b.background?B:u(B)},jsonp:function(b,k){var m=h();b=f(b,k);var x=new d(function(d,f){var h=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+u++,k=a.document.createElement("script");a[h]=function(f){k.parentNode.removeChild(k);d(p(b.type,f));delete a[h]};k.onerror=function(){k.parentNode.removeChild(k);f(Error("JSONP request failed"));delete a[h]};null==b.data&&(b.data={});b.url=g(b.url,b.data);b.data[b.callbackKey||
"callback"]=h;k.src=l(b.url,b.data);a.document.documentElement.appendChild(k)});return!0===b.background?x:m(x)},setCompletionCallback:function(a){x=a}}}(window,v),M=function(a){function d(a,c,e,b,d,f,g){for(;e<b;e++){var n=c[e];null!=n&&h(a,n,d,g,f)}}function h(a,c,e,b,g){var n=c.tag;null!=c.attrs&&v(c.attrs,c,e);if("string"===typeof n)switch(n){case "#":return c.dom=q.createTextNode(c.children),p(a,c.dom,g),c.dom;case "<":return f(a,c,g);case "[":var r=q.createDocumentFragment();null!=c.children&&
(n=c.children,d(r,n,0,n.length,e,null,b));c.dom=r.firstChild;c.domSize=r.childNodes.length;p(a,r,g);return r;default:var k=c.tag;switch(c.tag){case "svg":b="http://www.w3.org/2000/svg";break;case "math":b="http://www.w3.org/1998/Math/MathML"}var l=(n=c.attrs)&&n.is,k=b?l?q.createElementNS(b,k,{is:l}):q.createElementNS(b,k):l?q.createElement(k,{is:l}):q.createElement(k);c.dom=k;if(null!=n)for(r in l=b,n)y(c,r,null,n[r],l);p(a,k,g);null!=c.attrs&&null!=c.attrs.contenteditable?u(c):(null!=c.text&&(""!==
c.text?k.textContent=c.text:c.children=[w("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(a=c.children,d(k,a,0,a.length,e,null,b),a=c.attrs,"select"===c.tag&&null!=a&&("value"in a&&y(c,"value",null,a.value,void 0),"selectedIndex"in a&&y(c,"selectedIndex",null,a.selectedIndex,void 0))));return k}else{c.state=Object.create(c.tag);r=c.tag.view;if(null!=r.reentrantLock)c=L;else if(r.reentrantLock=!0,v(c.tag,c,e),c.instance=w.normalize(r.call(c.state,c)),r.reentrantLock=null,null!=c.instance){if(c.instance===
c)throw Error("A view cannot return the vnode it received as arguments");e=h(a,c.instance,e,b,g);c.dom=c.instance.dom;c.domSize=null!=c.dom?c.instance.domSize:0;p(a,e,g);c=e}else c.domSize=0,c=L;return c}}function f(a,c,b){var n={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(c.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div",n=q.createElement(n);n.innerHTML=c.children;c.dom=n.firstChild;c.domSize=n.childNodes.length;c=q.createDocumentFragment();
for(var e;e=n.firstChild;)c.appendChild(e);p(a,c,b);return c}function g(a,c,b,f,g,A,q){if(c!==b&&(null!=c||null!=b))if(null==c)d(a,b,0,b.length,g,A,void 0);else if(null==b)x(c,0,c.length,b);else{if(c.length===b.length){for(var n=!1,e=0;e<b.length;e++)if(null!=b[e]&&null!=c[e]){n=null==b[e].key&&null==c[e].key;break}if(n){for(e=0;e<c.length;e++)c[e]!==b[e]&&(null==c[e]&&null!=b[e]?h(a,b[e],g,q,m(c,e+1,A)):null==b[e]?x(c,e,e+1,b):l(a,c[e],b[e],g,m(c,e+1,A),!1,q));return}}if(!f)a:{if(null!=c.pool&&Math.abs(c.pool.length-
b.length)<=Math.abs(c.length-b.length)&&(f=b[0]&&b[0].children&&b[0].children.length||0,Math.abs((c.pool[0]&&c.pool[0].children&&c.pool[0].children.length||0)-f)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-f))){f=!0;break a}f=!1}f&&(c=c.concat(c.pool));for(var e=n=0,r=c.length-1,u=b.length-1,B;r>=n&&u>=e;){var t=c[n],y=b[e];if(t!==y||f)if(null==t)n++;else if(null==y)e++;else if(t.key===y.key)n++,e++,l(a,t,y,g,m(c,n,A),f,q),f&&t.tag===y.tag&&p(a,k(t),A);else if(t=c[r],t!==y||f)if(null==
t)r--;else if(null==y)e++;else if(t.key===y.key)l(a,t,y,g,m(c,r+1,A),f,q),(f||e<u)&&p(a,k(t),m(c,n,A)),r--,e++;else break;else r--,e++;else n++,e++}for(;r>=n&&u>=e;){t=c[r];y=b[u];if(t!==y||f)if(null==t)r--;else{if(null!=y)if(t.key===y.key)l(a,t,y,g,m(c,r+1,A),f,q),f&&t.tag===y.tag&&p(a,k(t),A),null!=t.dom&&(A=t.dom),r--;else{if(!B){B=c;var t=r,C={},v;for(v=0;v<t;v++){var w=B[v];null!=w&&(w=w.key,null!=w&&(C[w]=v))}B=C}null!=y&&(t=B[y.key],null!=t?(C=c[t],l(a,C,y,g,m(c,r+1,A),f,q),p(a,k(C),A),c[t].skip=
!0,null!=C.dom&&(A=C.dom)):A=h(a,y,g,void 0,A))}u--}else r--,u--;if(u<e)break}d(a,b,e,u+1,g,A,q);x(c,n,r+1,b)}}function l(a,c,e,d,p,q,t){var n=c.tag;if(n===e.tag){e.state=c.state;e.events=c.events;var r;var x;null!=e.attrs&&"function"===typeof e.attrs.onbeforeupdate&&(r=e.attrs.onbeforeupdate.call(e.state,e,c));"string"!==typeof e.tag&&"function"===typeof e.tag.onbeforeupdate&&(x=e.tag.onbeforeupdate.call(e.state,e,c));void 0===r&&void 0===x||r||x?r=!1:(e.dom=c.dom,e.domSize=c.domSize,e.instance=
c.instance,r=!0);if(!r)if(null!=e.attrs&&z(e.attrs,e,d,q),"string"===typeof n)switch(n){case "#":c.children.toString()!==e.children.toString()&&(c.dom.nodeValue=e.children);e.dom=c.dom;break;case "<":c.children!==e.children?(k(c),f(a,e,p)):(e.dom=c.dom,e.domSize=c.domSize);break;case "[":g(a,c.children,e.children,q,d,p,t);c=0;d=e.children;e.dom=null;if(null!=d){for(q=0;q<d.length;q++){var m=d[q];null!=m&&null!=m.dom&&(null==e.dom&&(e.dom=m.dom),c+=m.domSize||1)}1!==c&&(e.domSize=c)}break;default:a=
t;p=e.dom=c.dom;switch(e.tag){case "svg":a="http://www.w3.org/2000/svg";break;case "math":a="http://www.w3.org/1998/Math/MathML"}"textarea"===e.tag&&(null==e.attrs&&(e.attrs={}),null!=e.text&&(e.attrs.value=e.text,e.text=void 0));t=c.attrs;n=e.attrs;r=a;if(null!=n)for(m in n)y(e,m,t&&t[m],n[m],r);if(null!=t)for(m in t)null!=n&&m in n||("className"===m&&(m="class"),"o"!==m[0]||"n"!==m[1]||D(m)?"key"!==m&&e.dom.removeAttribute(m):K(e,m,void 0));null!=e.attrs&&null!=e.attrs.contenteditable?u(e):null!=
c.text&&null!=e.text&&""!==e.text?c.text.toString()!==e.text.toString()&&(c.dom.firstChild.nodeValue=e.text):(null!=c.text&&(c.children=[w("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=e.text&&(e.children=[w("#",void 0,void 0,e.text,void 0,void 0)]),g(p,c.children,e.children,q,d,null,a))}else e.instance=w.normalize(e.tag.view.call(e.state,e)),z(e.tag,e,d,q),null!=e.instance?(null==c.instance?h(a,e.instance,d,t,p):l(a,c.instance,e.instance,d,p,q,t),e.dom=e.instance.dom,e.domSize=e.instance.domSize):
null!=c.instance?(b(c.instance,null),e.dom=void 0,e.domSize=0):(e.dom=c.dom,e.domSize=c.domSize)}else b(c,null),h(a,e,d,t,p)}function k(a){var c=a.domSize;if(null!=c||null==a.dom){var b=q.createDocumentFragment();if(0<c){for(a=a.dom;--c;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function m(a,c,b){for(;c<a.length;c++)if(null!=a[c]&&null!=a[c].dom)return a[c].dom;return b}function p(a,c,b){b&&b.parentNode?a.insertBefore(c,b):a.appendChild(c)}function u(a){var c=
a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");}function x(a,c,e,d){for(;c<e;c++){var n=a[c];null!=n&&(n.skip?n.skip=!1:b(n,d))}}function b(a,c){function b(){if(++n===d&&(B(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var f=e.nextSibling,g=f.parentNode;null!=g&&g.removeChild(f)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b);
if(b=null!=c&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var d=1,n=0;if(a.attrs&&a.attrs.onbeforeremove){var f=a.attrs.onbeforeremove.call(a.state,a);null!=f&&"function"===typeof f.then&&(d++,f.then(b,b))}"string"!==typeof a.tag&&a.tag.onbeforeremove&&(f=a.tag.onbeforeremove.call(a.state,a),null!=f&&"function"===typeof f.then&&(d++,f.then(b,b)));b()}function B(a){a.attrs&&a.attrs.onremove&&
a.attrs.onremove.call(a.state,a);"string"!==typeof a.tag&&a.tag.onremove&&a.tag.onremove.call(a.state,a);if(null!=a.instance)B(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&B(b)}}function y(a,c,b,d,f){var e=a.dom;if("key"!==c&&"is"!==c&&(b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===q.activeElement||"object"===typeof d)&&"undefined"!==typeof d&&!D(c)){var g=c.indexOf(":");if(-1<g&&"xlink"===c.substr(0,g))e.setAttributeNS("http://www.w3.org/1999/xlink",
c.slice(g+1),d);else if("o"===c[0]&&"n"===c[1]&&"function"===typeof d)K(a,c,d);else if("style"===c)if(a=b,a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else{"string"===typeof a&&(e.style.cssText="");for(var n in d)e.style[n]=d[n];if(null!=a&&"string"!==typeof a)for(n in a)n in d||(e.style[n]="")}else c in e&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))?"input"===a.tag&&
"value"===c&&a.dom.value===d&&a.dom===q.activeElement||"select"===a.tag&&"value"===c&&a.dom.value===d&&a.dom===q.activeElement||"option"===a.tag&&"value"===c&&a.dom.value===d||(e[c]=d):"boolean"===typeof d?d?e.setAttribute(c,""):e.removeAttribute(c):e.setAttribute("className"===c?"class":c,d)}}function D(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function K(a,c,b){var d=a.dom,e="function"!==typeof H?b:function(a){var c=b.call(d,
a);H.call(d,a);return c};if(c in d)d[c]="function"===typeof b?e:null;else{var f=c.slice(2);void 0===a.events&&(a.events={});a.events[c]!==e&&(null!=a.events[c]&&d.removeEventListener(f,a.events[c],!1),"function"===typeof b&&(a.events[c]=e,d.addEventListener(f,a.events[c],!1)))}}function v(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function z(a,b,d,f){f?v(a,b,d):"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,
b))}var q=a.document,L=q.createDocumentFragment(),H;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=q.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);g(a,a.vnodes,w.normalizeChildren(b),!1,c,null,void 0);a.vnodes=b;for(var f=0;f<c.length;f++)c[f]();q.activeElement!==d&&d.focus()},setEventCallback:function(a){return H=a}}},F=function(a){function d(a){a=f.indexOf(a);-1<a&&f.splice(a,
2)}function h(){for(var a=1;a<f.length;a+=2)f[a]()}a=M(a);a.setEventCallback(function(a){!1!==a.redraw&&h()});var f=[];return{subscribe:function(a,h){d(a);f.push(a,O(h))},unsubscribe:d,redraw:h,render:a.render}}(window);I.setCompletionCallback(F.redraw);z.mount=function(a){return function(d,h){if(null===h)a.render(d,[]),a.unsubscribe(d);else{if(null==h.view)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(d,function(){a.render(d,w(h))});a.redraw()}}}(F);var Q=
v,J=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},h={},f=0;f<a.length;f++){var g=a[f].split("="),l=decodeURIComponent(g[0]),g=2===g.length?decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var k=l.split(/\]\[?|\[/),m=d;-1<l.indexOf("[")&&k.pop();for(var p=0;p<k.length;p++){var l=k[p],u=k[p+1],u=""==u||!isNaN(parseInt(u,10)),x=p===k.length-1;""===l&&(l=k.slice(0,p).join(),null==h[l]&&(h[l]=0),l=h[l]++);null==m[l]&&(m[l]=x?g:u?[]:
{});m=m[l]}}return d},R=function(a){function d(d){var f=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(a){return function(){null==k&&(k=l(function(){k=null;a()}))}}function f(a,d,f){var b=a.indexOf("?"),g=a.indexOf("#"),k=-1<b?b:-1<g?g:a.length;if(-1<b){var b=J(a.slice(b+1,-1<g?g:a.length)),h;for(h in b)d[h]=b[h]}if(-1<g)for(h in d=J(a.slice(g+1)),d)f[h]=d[h];return a.slice(0,k)}var g="function"===typeof a.history.pushState,
l="function"===typeof setImmediate?setImmediate:setTimeout,k,m={prefix:"#!",getPath:function(){switch(m.prefix.charAt(0)){case "#":return d("hash").slice(m.prefix.length);case "?":return d("search").slice(m.prefix.length)+d("hash");default:return d("pathname").slice(m.prefix.length)+d("search")+d("hash")}},setPath:function(d,h,k){var b={},l={};d=f(d,b,l);if(null!=h){for(var p in h)b[p]=h[p];d=d.replace(/:([^\/]+)/g,function(a,d){delete b[d];return h[d]})}(p=E(b))&&(d+="?"+p);(l=E(l))&&(d+="#"+l);
g?(l=k?k.state:null,p=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(l,p,m.prefix+d):a.history.pushState(l,p,m.prefix+d)):a.location.href=m.prefix+d},defineRoutes:function(d,k,l){function b(){var b=m.getPath(),g={},h=f(b,g,g),p=a.history.state;if(null!=p)for(var x in p)g[x]=p[x];for(var u in d)if(p=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(h)){h.replace(p,function(){for(var a=u.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,
1,-2),h=0;h<a.length;h++)g[a[h].replace(/:|\./g,"")]=decodeURIComponent(f[h]);k(d[u],g,b,u)});return}l(b,g)}g?a.onpopstate=h(b):"#"===m.prefix.charAt(0)&&(a.onhashchange=b);b()}};return m};z.route=function(a,d){var h=R(a),f=function(a){return a},g,l,k,m,p,u=function(a,b,u){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var x=function(){null!=g&&d.render(a,g(w(l,k.key,k)))},v=function(a){if(a!==b)h.setPath(b,null,{replace:!0});else throw Error("Could not resolve default route "+
b);};h.defineRoutes(u,function(a,b,d){var h=p=function(a,q){h===p&&(l=null!=q&&"function"===typeof q.view?q:"div",k=b,m=d,p=null,g=(a.render||f).bind(a),x())};a.view?h({},a):a.onmatch?Q.resolve(a.onmatch(b,d)).then(function(b){h(a,b)},v):h(a,"div")},v);d.subscribe(a,x)};u.set=function(a,b,d){null!=p&&(d={replace:!0});p=null;h.setPath(a,b,d)};u.get=function(){return m};u.prefix=function(a){h.prefix=a};u.link=function(a){a.dom.setAttribute("href",h.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||
a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),u.set(a,void 0,void 0))}};u.param=function(a){return"undefined"!==typeof k&&"undefined"!==typeof a?k[a]:k};return u}(window,F);z.withAttr=function(a,d,h){return function(f){d.call(h||this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var S=M(window);z.render=S.render;z.redraw=F.redraw;z.request=I.request;z.jsonp=I.jsonp;
z.parseQueryString=J;z.buildQueryString=E;z.version="1.0.1";z.vnode=w;"undefined"!==typeof module?module.exports=z:window.m=z};
{
"name": "mithril",
"version": "1.0.0",
"version": "1.0.1",
"description": "A framework for building brilliant applications",

@@ -5,0 +5,0 @@ "author": "Leo Horie",

@@ -18,8 +18,2 @@ # Introduction

<style>
@keyframes grow {
from {transform:scaleX(0)}
to {transform:scaleX(100%)}
}
</style>
<div style="display:flex;margin:0 0 30px;">

@@ -63,9 +57,10 @@ <div style="width:50%;">

```markup
<body></body>
<script src="http://unpkg.com/mithril/mithril.js"></script>
<script>
var root = document.body
<body>
<script src="//unpkg.com/mithril/mithril.js"></script>
<script>
var root = document.body
// your code goes here!
</script>
// your code goes here!
</script>
</body>
```

@@ -234,3 +229,3 @@

First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `data` is the payload that we're sending to the endpoint and `useCredentials` means to enable cookies (a requirement for the REM API to work)
First we create a function that calls `m.request`. The `url` specifies an endpoint that represents a resource, the `method` specifies the type of action we're taking (typically the `PUT` method [upserts](https://en.wiktionary.org/wiki/upsert)), `data` is the payload that we're sending to the endpoint and `withCredentials` means to enable cookies (a requirement for the REM API to work)

@@ -242,5 +237,5 @@ ```javascript

method: "PUT",
url: "http://rem-rest-api.herokuapp.com/api/tutorial/1",
url: "//rem-rest-api.herokuapp.com/api/tutorial/1",
data: {count: count + 1},
useCredentials: true,
withCredentials: true,
})

@@ -247,0 +242,0 @@ .then(function(data) {

@@ -17,7 +17,7 @@ "use strict"

if (vnode != null) {
insertNode(parent, createNode(vnode, hooks, ns), nextSibling)
createNode(parent, vnode, hooks, ns, nextSibling)
}
}
}
function createNode(vnode, hooks, ns) {
function createNode(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag

@@ -27,17 +27,19 @@ if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks)

switch (tag) {
case "#": return createText(vnode)
case "<": return createHTML(vnode)
case "[": return createFragment(vnode, hooks, ns)
default: return createElement(vnode, hooks, ns)
case "#": return createText(parent, vnode, nextSibling)
case "<": return createHTML(parent, vnode, nextSibling)
case "[": return createFragment(parent, vnode, hooks, ns, nextSibling)
default: return createElement(parent, vnode, hooks, ns, nextSibling)
}
}
else return createComponent(vnode, hooks, ns)
else return createComponent(parent, vnode, hooks, ns, nextSibling)
}
function createText(vnode) {
return vnode.dom = $doc.createTextNode(vnode.children)
function createText(parent, vnode, nextSibling) {
vnode.dom = $doc.createTextNode(vnode.children)
insertNode(parent, vnode.dom, nextSibling)
return vnode.dom
}
function createHTML(vnode) {
function createHTML(parent, vnode, nextSibling) {
var match = vnode.children.match(/^\s*?<(\w+)/im) || []
var parent = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match[1]] || "div"
var temp = $doc.createElement(parent)
var parent1 = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}[match[1]] || "div"
var temp = $doc.createElement(parent1)

@@ -52,5 +54,6 @@ temp.innerHTML = vnode.children

}
insertNode(parent, fragment, nextSibling)
return fragment
}
function createFragment(vnode, hooks, ns) {
function createFragment(parent, vnode, hooks, ns, nextSibling) {
var fragment = $doc.createDocumentFragment()

@@ -63,5 +66,6 @@ if (vnode.children != null) {

vnode.domSize = fragment.childNodes.length
insertNode(parent, fragment, nextSibling)
return fragment
}
function createElement(vnode, hooks, ns) {
function createElement(parent, vnode, hooks, ns, nextSibling) {
var tag = vnode.tag

@@ -85,2 +89,4 @@ switch (vnode.tag) {

insertNode(parent, element, nextSibling)
if (vnode.attrs != null && vnode.attrs.contenteditable != null) {

@@ -102,3 +108,3 @@ setContentEditable(vnode)

}
function createComponent(vnode, hooks, ns) {
function createComponent(parent, vnode, hooks, ns, nextSibling) {
vnode.state = Object.create(vnode.tag)

@@ -113,5 +119,6 @@ var view = vnode.tag.view

if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
var element = createNode(vnode.instance, hooks, ns)
var element = createNode(parent, vnode.instance, hooks, ns, nextSibling)
vnode.dom = vnode.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
insertNode(parent, element, nextSibling)
return element

@@ -126,3 +133,3 @@ }

//update
function updateNodes(parent, old, vnodes, hooks, nextSibling, ns) {
function updateNodes(parent, old, vnodes, recycling, hooks, nextSibling, ns) {
if (old === vnodes || old == null && vnodes == null) return

@@ -143,3 +150,3 @@ else if (old == null) createNodes(parent, vnodes, 0, vnodes.length, hooks, nextSibling, undefined)

if (old[i] === vnodes[i]) continue
else if (old[i] == null && vnodes[i] != null) insertNode(parent, createNode(vnodes[i], hooks, ns), getNextSibling(old, i + 1, nextSibling))
else if (old[i] == null && vnodes[i] != null) createNode(parent, vnodes[i], hooks, ns, getNextSibling(old, i + 1, nextSibling))
else if (vnodes[i] == null) removeNodes(old, i, i + 1, vnodes)

@@ -151,5 +158,5 @@ else updateNode(parent, old[i], vnodes[i], hooks, getNextSibling(old, i + 1, nextSibling), false, ns)

}
var recycling = isRecyclable(old, vnodes)
recycling = recycling || isRecyclable(old, vnodes)
if (recycling) old = old.concat(old.pool)
var oldStart = 0, start = 0, oldEnd = old.length - 1, end = vnodes.length - 1, map

@@ -202,4 +209,3 @@ while (oldEnd >= oldStart && end >= start) {

else {
var dom = createNode(v, hooks, undefined)
insertNode(parent, dom, nextSibling)
var dom = createNode(parent, v, hooks, undefined, nextSibling)
nextSibling = dom

@@ -229,4 +235,4 @@ }

case "<": updateHTML(parent, old, vnode, nextSibling); break
case "[": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break
default: updateElement(old, vnode, hooks, ns)
case "[": updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns); break
default: updateElement(old, vnode, recycling, hooks, ns)
}

@@ -238,3 +244,3 @@ }

removeNode(old, null)
insertNode(parent, createNode(vnode, hooks, ns), nextSibling)
createNode(parent, vnode, hooks, ns, nextSibling)
}

@@ -251,8 +257,8 @@ }

toFragment(old)
insertNode(parent, createHTML(vnode), nextSibling)
createHTML(parent, vnode, nextSibling)
}
else vnode.dom = old.dom, vnode.domSize = old.domSize
}
function updateFragment(parent, old, vnode, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns)
function updateFragment(parent, old, vnode, recycling, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, recycling, hooks, nextSibling, ns)
var domSize = 0, children = vnode.children

@@ -271,3 +277,3 @@ vnode.dom = null

}
function updateElement(old, vnode, hooks, ns) {
function updateElement(old, vnode, recycling, hooks, ns) {
var element = vnode.dom = old.dom

@@ -295,3 +301,3 @@ switch (vnode.tag) {

if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)]
updateNodes(element, old.children, vnode.children, hooks, null, ns)
updateNodes(element, old.children, vnode.children, recycling, hooks, null, ns)
}

@@ -303,3 +309,3 @@ }

if (vnode.instance != null) {
if (old.instance == null) insertNode(parent, createNode(vnode.instance, hooks, ns), nextSibling)
if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling)
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, recycling, ns)

@@ -582,3 +588,3 @@ vnode.dom = vnode.instance.dom

if (!Array.isArray(vnodes)) vnodes = [vnodes]
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), hooks, null, undefined)
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, undefined)
dom.vnodes = vnodes

@@ -585,0 +591,0 @@ for (var i = 0; i < hooks.length; i++) hooks[i]()

@@ -190,3 +190,3 @@ "use strict"

o(vnode.dom).equals(undefined)
o(root.childNodes.length).equals(0)
o(root.childNodes.length).equals(1)
}

@@ -193,0 +193,0 @@ o(called).equals(true)

@@ -24,3 +24,3 @@ "use strict"

})
o("throws on invalid root node", function() {

@@ -35,3 +35,3 @@ var threw = false

})
o("does not enter infinite loop when oninit triggers render and view throws", function(done) {

@@ -49,3 +49,3 @@ var A = {

try {run()} catch (e) {threwInner = true}
o(threwInner).equals(false)

@@ -55,8 +55,38 @@ done()

}
var threwOuter = false
try {run()} catch (e) {threwOuter = true}
o(threwOuter).equals(true)
})
o("lifecycle methods work in children of recycled", function() {
var createA = o.spy()
var updateA = o.spy()
var removeA = o.spy()
var createB = o.spy()
var updateB = o.spy()
var removeB = o.spy()
var a = function() {
return {tag: "div", key: 1, children: [
{tag: "div", key: 11, attrs: {oncreate: createA, onupdate: updateA, onremove: removeA}},
{tag: "div", key: 12}
]}
}
var b = function() {
return {tag: "div", key: 2, children: [
{tag: "div", key: 21, attrs: {oncreate: createB, onupdate: updateB, onremove: removeB}},
{tag: "div", key: 22}
]}
}
render(root, a())
render(root, b())
render(root, a())
o(createA.callCount).equals(2)
o(updateA.callCount).equals(0)
o(removeA.callCount).equals(1)
o(createB.callCount).equals(1)
o(updateB.callCount).equals(0)
o(removeB.callCount).equals(1)
})
})

@@ -83,3 +83,3 @@ "use strict"

var pathname = parsePath(path, params, params)
var state = $window.history.state

@@ -107,3 +107,3 @@ if (state != null) {

}
if (supportsPushState) $window.onpopstate = debounceAsync(resolveRoute)

@@ -113,4 +113,4 @@ else if (router.prefix.charAt(0) === "#") $window.onhashchange = resolveRoute

}
return router
}

@@ -14,7 +14,7 @@ "use strict"

})
o.spec("m", function() {
o("works", function() {
var vnode = m("div")
o(vnode.tag).equals("div")

@@ -33,3 +33,3 @@ })

var vnode = m.trust("<br>")
o(vnode.tag).equals("<")

@@ -42,3 +42,3 @@ o(vnode.children).equals("<br>")

var vnode = m.fragment({key: 123}, [m("div")])
o(vnode.tag).equals("[")

@@ -54,5 +54,5 @@ o(vnode.key).equals(123)

var handler = m.withAttr("value", spy)
handler({currentTarget: {value: 10}})
o(spy.args[0]).equals(10)

@@ -64,3 +64,3 @@ })

var query = m.parseQueryString("?a=1&b=2")
o(query).deepEquals({a: "1", b: "2"})

@@ -72,3 +72,3 @@ })

var query = m.buildQueryString({a: 1, b: 2})
o(query).equals("a=1&b=2")

@@ -81,3 +81,3 @@ })

m.render(root, m("div"))
o(root.childNodes.length).equals(1)

@@ -91,3 +91,3 @@ o(root.firstChild.nodeName).equals("DIV")

m.mount(root, {view: function() {return m("div")}})
o(root.childNodes.length).equals(1)

@@ -103,7 +103,7 @@ o(root.firstChild.nodeName).equals("DIV")

})
setTimeout(function() {
o(root.childNodes.length).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()

@@ -118,7 +118,7 @@ }, FRAME_BUDGET)

})
setTimeout(function() {
o(root.childNodes.length).equals(1)
o(root.firstChild.nodeName).equals("DIV")
done()

@@ -132,6 +132,6 @@ }, FRAME_BUDGET)

})
setTimeout(function() {
o(m.route.get()).equals("/a")
done()

@@ -146,3 +146,3 @@ }, FRAME_BUDGET)

})
setTimeout(function() {

@@ -152,3 +152,3 @@ m.route.set("/b")

o(m.route.get()).equals("/b")
done()

@@ -166,5 +166,5 @@ }, FRAME_BUDGET)

m.redraw()
o(count).equals(2)
done()

@@ -184,2 +184,2 @@ }, FRAME_BUDGET)

})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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