Comparing version 1.1.6 to 1.1.7
@@ -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. 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). | ||
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 positioned element over a fixed element). |
# Change log | ||
- [v1.1.7](#v117) | ||
- [v1.1.6](#v116) | ||
@@ -16,2 +17,10 @@ - [v1.1.5](#v115) | ||
### v1.1.7 | ||
#### Bug fixes | ||
- core: Workaround for [Internet Explorer bug](https://www.tjvantoll.com/2013/08/30/bugs-with-document-activeelement-in-internet-explorer/) when running in an iframe | ||
- Fix prototype pollution vulnerability in `m.parseQueryString` ([#2523](https://github.com/MithrilJS/mithril.js/pull/2523) [@isiahmeadows](https://github.com/isiahmeadows) [@Hunter-Dolan](https://github.com/Hunter-Dolan)) | ||
### v1.1.6 | ||
@@ -18,0 +27,0 @@ |
@@ -58,3 +58,3 @@ # Contributor Covenant Code of Conduct | ||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at [github@patcavit.com](mailto:github@patcavit.com?subject=Mithril Code of Conduct). All | ||
reported by contacting the project team at [github@patcavit.com](mailto:github@patcavit.com?subject=Mithril%20Code%20of%20Conduct). All | ||
complaints will be reviewed and investigated and will result in a response that | ||
@@ -61,0 +61,0 @@ is deemed necessary and appropriate to the circumstances. The project team is |
@@ -64,2 +64,5 @@ # Components | ||
}, | ||
onbeforeupdate: function(vnode, old) { | ||
return true | ||
}, | ||
onupdate: function(vnode) { | ||
@@ -78,5 +81,2 @@ console.log("DOM updated") | ||
}, | ||
onbeforeupdate: function(vnode, old) { | ||
return true | ||
}, | ||
view: function(vnode) { | ||
@@ -182,3 +182,3 @@ return "hello" | ||
// EXAMPLE: via m.mount | ||
m.mount(document.body, closuresComponent) | ||
m.mount(document.body, closureComponent) | ||
@@ -185,0 +185,0 @@ // EXAMPLE: via m.route |
@@ -90,3 +90,3 @@ # CSS | ||
Often sacrifices also need to be made at time of debugging, when mapping rendered CSS class names back to their source. Often all you get in browser developer tools is a class like `button_fvp6zc2gdj35evhsl73ffzq_0 danger_fgdl0s2a5fmle5g56rbuax71_0` with useless source maps (or worse, entirely criptic class names). | ||
Often sacrifices also need to be made at time of debugging, when mapping rendered CSS class names back to their source. Often all you get in browser developer tools is a class like `button_fvp6zc2gdj35evhsl73ffzq_0 danger_fgdl0s2a5fmle5g56rbuax71_0` with useless source maps (or worse, entirely cryptic class names). | ||
@@ -93,0 +93,0 @@ Another common issue is lack of support for less basic CSS features such as `@keyframes` and `@font-face`. |
@@ -15,5 +15,2 @@ "use strict" | ||
var index = fs.readFileSync("docs/index.md", "utf-8") | ||
fs.writeFileSync("README.md", index.replace(/(\]\()(.+?)\.md(\))/g, "$1http://mithril.js.org/$2.html$3"), "utf-8") | ||
generate("docs") | ||
@@ -20,0 +17,0 @@ |
@@ -228,3 +228,3 @@ # Introduction | ||
Now that we going to have more than one screen, we use `m.route` instead of `m.mount`. | ||
Now that we're going to have more than one screen, we use `m.route` instead of `m.mount`. | ||
@@ -231,0 +231,0 @@ ```javascript |
@@ -5,2 +5,4 @@ # Installation | ||
- [NPM](#npm) | ||
- [Quick start with Webpack](#quick-start-with-webpack) | ||
- [TypeScript](#typescript) | ||
@@ -19,26 +21,52 @@ ### CDN | ||
#### Quick start with Webpack | ||
```bash | ||
# 1) install | ||
npm install mithril --save | ||
$ npm install mithril --save | ||
``` | ||
npm install webpack --save | ||
--- | ||
# 2) add this line into the scripts section in package.json | ||
# "scripts": { | ||
# "start": "webpack src/index.js bin/app.js --watch" | ||
# } | ||
### Quick start with Webpack | ||
# 3) create an `src/index.js` file | ||
1. Initialize the directory as an npm package | ||
```bash | ||
$ npm init --yes | ||
``` | ||
# 4) create an `index.html` file containing `<script src="bin/app.js"></script>` | ||
2. install required tools | ||
```bash | ||
$ npm install mithril --save | ||
$ npm install webpack webpack-cli --save-dev | ||
``` | ||
# 5) run bundler | ||
npm start | ||
3. Add a "start" entry to the scripts section in `package.json`. | ||
```js | ||
{ | ||
// ... | ||
"scripts": { | ||
"start": "webpack src/index.js --output bin/app.js -d --watch" | ||
} | ||
} | ||
``` | ||
# 6) open `index.html` in the (default) browser | ||
open index.html | ||
4. Create `src/index.js` file. | ||
```js | ||
import m from "mithril"; | ||
m.render(document.body, "hello world"); | ||
``` | ||
5. create `index.html` | ||
```html | ||
<!DOCTYPE html> | ||
<body> | ||
<script src="bin/app.js"></script> | ||
</body> | ||
``` | ||
6. run bundler | ||
```bash | ||
$ npm start | ||
``` | ||
7. open `index.html` in a browser | ||
#### Step by step | ||
@@ -83,3 +111,3 @@ | ||
```bash | ||
npm install webpack --save-dev | ||
npm install webpack webpack-cli --save-dev | ||
``` | ||
@@ -93,3 +121,3 @@ | ||
"scripts": { | ||
"start": "webpack src/index.js bin/app.js -d --watch" | ||
"start": "webpack src/index.js --output bin/app.js -d --watch" | ||
} | ||
@@ -156,4 +184,4 @@ } | ||
"scripts": { | ||
"start": "webpack src/index.js bin/app.js -d --watch", | ||
"build": "webpack src/index.js bin/app.js -p", | ||
"start": "webpack src/index.js --output bin/app.js -d --watch", | ||
"build": "webpack src/index.js --output bin/app.js -p", | ||
} | ||
@@ -239,1 +267,13 @@ } | ||
``` | ||
--- | ||
### TypeScript | ||
TypeScript type definitions are available from DefinitelyTyped. They can be installed with: | ||
```bash | ||
$ npm install @types/mithril --save-dev | ||
``` | ||
For example usage, to file issues or to discuss TypeScript related topics visit: https://github.com/MithrilJS/mithril.d.ts |
@@ -101,3 +101,3 @@ # JSX | ||
``` | ||
```json | ||
{ | ||
@@ -125,3 +125,3 @@ "presets": ["es2015"], | ||
module: { | ||
loaders: [{ | ||
rules: [{ | ||
test: /\.js$/, | ||
@@ -135,2 +135,4 @@ exclude: /node_modules/, | ||
For those familiar with Webpack already, please note that adding the Babel options to the `babel-loader` section of your `webpack.config.js` will throw an error, so you need to include them in the separate `.babelrc` file. | ||
This configuration assumes the source code file for the application entry point is in `src/index.js`, and this will output the bundle to `bin/app.js`. | ||
@@ -195,3 +197,3 @@ | ||
- it does not require repeating the tag name in closing tags (e.g. `m("div")` vs `<div></div>`) | ||
- static attributes can be written using CSS selector syntax (i.e. `m("a.button")` vs `<div class="button"></div>` | ||
- static attributes can be written using CSS selector syntax (i.e. `m("a.button")` vs `<a class="button"></a>`) | ||
@@ -198,0 +200,0 @@ In addition, since hyperscript is plain Javascript, it's often more natural to indent than JSX: |
@@ -183,3 +183,3 @@ # Keys | ||
The `key` property may appear in your data model in a way that conflicts with Mithril's key logic. For example, a component may represent an entity whose `key` property is expected to change over time. This can lead to components receiving the wrong data, re-initialise, or change positions unexpectedly. If your data model uses the `key` property, make sure to wrap the data such that Mithril doesn't misinterpret it as a rendering instruction: | ||
The `key` property may appear in your data model in a way that conflicts with Mithril's key logic. For example, a component may represent an entity whose `key` property is expected to change over time. This can lead to components receiving the wrong data, re-initialize, or change positions unexpectedly. If your data model uses the `key` property, make sure to wrap the data such that Mithril doesn't misinterpret it as a rendering instruction: | ||
@@ -186,0 +186,0 @@ ```javascript |
@@ -38,3 +38,3 @@ # mount(root, component) | ||
`m.mount(element, component)` | ||
`m.mount(element, Component)` | ||
@@ -44,3 +44,3 @@ Argument | Type | Required | Description | ||
`element` | `Element` | Yes | A DOM element that will be the parent node to the subtree | ||
`component` | `Component|null` | Yes | The [component](components.md) to be rendered. `null` unmounts the tree and cleans up internal state. | ||
`Component` | `Component|null` | Yes | The [component](components.md) to be rendered. `null` unmounts the tree and cleans up internal state. | ||
**returns** | | | Returns nothing | ||
@@ -54,4 +54,6 @@ | ||
Similar to [`m.render()`](render.md), the `m.mount()` method takes a component and mounts a corresponding DOM tree into `element`. If `element` already has a DOM tree mounted via a previous `m.mount()` call, the component is diffed against the previous vnode tree and the existing DOM tree is modified only where needed to reflect the changes. Unchanged DOM nodes are not touched at all. | ||
`m.mount(element, Component)`, when called renders the component into the element and subscribe the `(element, Component)` pair to the redraw subsystem. That tree will be re-rendered when [manual](redraw.md) or [automatic](autoredraw.md) redraws are triggered. | ||
On redraw, the new vDOM tree is compared (or "diffed") with the old one, and the existing DOM tree is modified only where needed to reflect the changes. Unchanged DOM nodes are not touched at all. | ||
#### Replace a component | ||
@@ -79,3 +81,3 @@ | ||
A component rendered via `m.mount` automatically auto-redraws in response to view events, `m.redraw()` calls or `m.request()` calls. Vnodes rendered via `m.render()` do not. | ||
A component rendered via `m.mount` [automatically redraws](autoredraw.md) in response to view events, `m.redraw()` calls or `m.request()` calls. Vnodes rendered via `m.render()` do not. | ||
@@ -82,0 +84,0 @@ `m.mount()` is suitable for application developers integrating Mithril widgets into existing codebases where routing is handled by another library or framework, while still enjoying Mithril's auto-redrawing facilities. |
@@ -1,5 +0,7 @@ | ||
- Tutorials | ||
- Getting Started | ||
- [Introduction](index.md) | ||
- [Installation](installation.md) | ||
- [Introduction](index.md) | ||
- [Tutorial](simple-application.md) | ||
- [Learning Resources](learning-mithril.md) | ||
- [Getting Help](support.md) | ||
- Resources | ||
@@ -12,2 +14,3 @@ - [JSX](jsx.md) | ||
- [Examples](examples.md) | ||
- [3rd Party Integration](integrating-libs.md) | ||
- Key concepts | ||
@@ -14,0 +17,0 @@ - [Vnodes](vnodes.md) |
@@ -305,3 +305,3 @@ # Promise(executor) | ||
Callbacks are another mechanism for working with asynchrounous computations, and are indeed more adequate to use if an asynchronous computation may occur more than one time (for example, an `onscroll` event handler). | ||
Callbacks are another mechanism for working with asynchronous computations, and are indeed more adequate to use if an asynchronous computation may occur more than one time (for example, an `onscroll` event handler). | ||
@@ -308,0 +308,0 @@ However, for asynchronous computations that only occur once in response to an action, promises can be refactored more effectively, reducing code smells known as pyramids of doom (deeply nested series of callbacks with unmanaged state being used across several closure levels). |
@@ -13,3 +13,3 @@ # redraw() | ||
You DON'T need to call it if data is modified within the execution context of an event handler defined in a Mithril view, or after request completion when using `m.request`/`m.jsonp`. | ||
You DON'T need to call it if data is modified within the execution context of an event handler defined in a Mithril view, or after request completion when using `m.request`/`m.jsonp`. The [autoredraw](autoredraw.md) system, which is built on top of `m.redraw()` will take care of it. | ||
@@ -16,0 +16,0 @@ You DO need to call it in `setTimeout`/`setInterval`/`requestAnimationFrame` callbacks, or callbacks from 3rd party libraries. |
@@ -5,2 +5,6 @@ # Mithril Release Processes | ||
- [Releasing a new Mithril version](#releasing-a-new-mithril-version) | ||
- [Updating mithril.js.org](#updating-mithriljsorg) | ||
- [Releasing a new ospec version](#releasing-a-new-ospec-version) | ||
## Releasing a new Mithril version | ||
@@ -13,3 +17,3 @@ | ||
```bash | ||
$ git co next | ||
$ git checkout next | ||
$ git pull --rebase mithriljs next | ||
@@ -38,3 +42,3 @@ ``` | ||
```bash | ||
$ git co master | ||
$ git checkout master | ||
$ git pull --rebase mithriljs master | ||
@@ -76,3 +80,3 @@ ``` | ||
```bash | ||
$ git co next | ||
$ git checkout next | ||
$ git pull --rebase mithriljs next | ||
@@ -106,8 +110,8 @@ ``` | ||
# Ensure your next branch is up to date | ||
$ git co next | ||
$ git checkout next | ||
$ git pull mithriljs next | ||
# Splat the docs folder from next onto master | ||
$ git co master | ||
$ git co next -- ./docs | ||
$ git checkout master | ||
$ git checkout next -- ./docs | ||
@@ -120,1 +124,59 @@ # Manually ensure that no new feature docs were added | ||
After the Travis build completes the updated docs should appear on https://mithril.js.org in a few minutes. | ||
## Releasing a new ospec version | ||
1. Ensure your local branch is up to date | ||
```bash | ||
$ git checkout next | ||
$ git pull --rebase mithriljs next | ||
``` | ||
2. Determine patch level of the change | ||
3. Update `version` field in `ospec/package.json` to match new version being prepared for release | ||
4. Commit changes to `next` | ||
``` | ||
$ git add . | ||
$ git commit -m "chore(ospec): ospec@<version>" | ||
# Push to your branch | ||
$ git push | ||
# Push to MithrilJS/mithril.js | ||
$ git push mithriljs next | ||
``` | ||
### Merge from `next` to `master` | ||
5. Switch to `master` and make sure it's up to date | ||
```bash | ||
$ git checkout master | ||
$ git pull --rebase mithriljs master | ||
``` | ||
6. merge `next` on top of it | ||
```bash | ||
$ git checkout next -- ./ospec | ||
$ git add . | ||
$ git commit -m "chore(ospec): ospec@<version>" | ||
``` | ||
7. Ensure the tests are passing! | ||
### Publish the release | ||
8. Push the changes to `MithrilJS/mithril.js` | ||
```bash | ||
$ git push mithriljs master | ||
``` | ||
9. Publish the changes to npm **from the `/ospec` folder**. That bit is important to ensure you don't accidentally ship a new Mithril release! | ||
```bash | ||
$ cd ./ospec | ||
$ npm publish | ||
``` |
@@ -39,3 +39,3 @@ # render(element, vnodes) | ||
The `m.render(element, vnodes)` method takes a virtual DOM tree (typically generated via the [`m()` hyperscript function](hyperscript.md), generates a DOM tree and mounts it on `element`. If `element` already has a DOM tree mounted via a previous `m.render()` call, `vnodes` is diffed against the previous `vnodes` tree and the existing DOM tree is modified only where needed to reflect the changes. Unchanged DOM nodes are not touched at all. | ||
The `m.render(element, vnodes)` method takes a virtual DOM tree (typically generated via the [`m()` hyperscript function](hyperscript.md)), generates a DOM tree and mounts it on `element`. If `element` already has a DOM tree mounted via a previous `m.render()` call, `vnodes` is diffed against the previous `vnodes` tree and the existing DOM tree is modified only where needed to reflect the changes. Unchanged DOM nodes are not touched at all. | ||
@@ -72,2 +72,2 @@ `m.render` is synchronous. | ||
Despite being incredibly small, the render module is fully functional and self-suficient. It supports everything you might expect: SVG, custom elements, and all valid attributes and events - without any weird case-sensitive edge cases or exceptions. Of course, it also fully supports [components](components.md) and [lifecycle methods](lifecycle-methods.md). | ||
Despite being incredibly small, the render module is fully functional and self-sufficient. It supports everything you might expect: SVG, custom elements, and all valid attributes and events - without any weird case-sensitive edge cases or exceptions. Of course, it also fully supports [components](components.md) and [lifecycle methods](lifecycle-methods.md). |
@@ -52,2 +52,3 @@ # request(options) | ||
`options.withCredentials` | `Boolean` | No | Whether to send cookies to 3rd party domains. Defaults to `false` | ||
`options.timeout` | `Number` | No | The amount of milliseconds a request can take before automatically being [terminated](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/timeout). Defaults to `undefined`. | ||
`options.config` | `xhr = Function(xhr)` | No | Exposes the underlying XMLHttpRequest object for low-level configuration. Defaults to the [identity function](https://en.wikipedia.org/wiki/Identity_function). | ||
@@ -58,3 +59,3 @@ `options.headers` | `Object` | No | Headers to append to the request before sending it (applied right before `options.config`). | ||
`options.deserialize` | `any = Function(string)` | No | A deserialization method to be applied to the `xhr.responseText`. Defaults to a small wrapper around `JSON.parse` that returns `null` for empty responses. If `extract` is defined, `deserialize` will be skipped. | ||
`options.extract` | `any = Function(xhr, options)` | No | A hook to specify how the XMLHttpRequest response should be read. Useful for processing response data, reading headers and cookies. By default this is a function that returns `xhr.responseText`, which is in turn passed to `deserialize`. If a custom `extract` callback is provided, the `xhr` parameter is the XMLHttpRequest instance used for the request, and `options` is the object that was passed to the `m.request` call. Additionally, `deserialize` will be skipped and the value returned from the extract callback will not automatically be parsed as JSON. | ||
`options.extract` | `any = Function(xhr, options)` | No | A hook to specify how the XMLHttpRequest response should be read. Useful for processing response data, reading headers and cookies. By default this is a function that returns `xhr.responseText`, which is in turn passed to `deserialize`. If a custom `extract` callback is provided, the `xhr` parameter is the XMLHttpRequest instance used for the request, and `options` is the object that was passed to the `m.request` call. Additionally, `deserialize` will be skipped and the value returned from the extract callback will be left as-is when the promise resolves. Furthermore, when an extract callback is provided, exceptions are *not* thrown when the server response status code indicates an error. | ||
`options.useBody` | `Boolean` | No | Force the use of the HTTP body section for `data` in `GET` requests when set to `true`, or the use of querystring for other HTTP methods when set to `false`. Defaults to `false` for `GET` requests and `true` for other methods. | ||
@@ -86,2 +87,4 @@ `options.background` | `Boolean` | No | If `false`, redraws mounted components upon completion of the request. If `true`, it does not. Defaults to `false`. | ||
If the HTTP response status code indicates an error, the returned Promise will be rejected. Supplying an extract callback will prevent the promise rejection. | ||
--- | ||
@@ -335,3 +338,3 @@ | ||
config: function(xhr) { | ||
xhr.addEventListener("progress", function(e) { | ||
xhr.upload.addEventListener("progress", function(e) { | ||
progress = e.loaded / e.total | ||
@@ -433,3 +436,3 @@ | ||
By default Mithril attempts to parse a response as JSON and returns `xhr.responseText`. It may be useful to inspect a server response in more detail, this can be accomplished by passing a custom `options.extract` function: | ||
By default Mithril attempts to parse `xhr.responseText` as JSON and returns the parsed object. It may be useful to inspect a server response in more detail and process it manually. This can be accomplished by passing a custom `options.extract` function: | ||
@@ -436,0 +439,0 @@ ```javascript |
@@ -68,3 +68,3 @@ # route(root, defaultRoute, routes) | ||
Redirects to a matching route, or to the default route if no matching routes can be found. | ||
Redirects to a matching route, or to the default route if no matching routes can be found. Triggers an asynchronous redraw off all mount points. | ||
@@ -108,6 +108,6 @@ `m.route.set(path, data, options)` | ||
```JS | ||
m("a[href=/]", {oncreate: m.route.link})`. | ||
m("a[href=/]", {oncreate: m.route.link}) | ||
``` | ||
Using `m.route.link` as a `oncreate` hook causes the link to behave as a router link (i.e. it navigates to the route specified in `href`, instead of nagivating away from the current page to the URL specified in `href`. | ||
Using `m.route.link` as a `oncreate` hook causes the link to behave as a router link (i.e. it navigates to the route specified in `href`, instead of navigating away from the current page to the URL specified in `href`. | ||
@@ -117,12 +117,18 @@ If the `href` attribute is not static, the `onupdate` hook must also be set: | ||
```JS | ||
m("a", {href: someVariable, oncreate: m.route.link, onupdate: m.route.link})` | ||
m("a", {href: someVariable, oncreate: m.route.link, onupdate: m.route.link}) | ||
``` | ||
`m.route.link(vnode)` | ||
`m.route.link` can also set the `options` passed to `m.route.set` when the link is clicked by calling the function in the lifecycle methods: | ||
Argument | Type | Required | Description | ||
----------------- | ----------- | -------- | --- | ||
`vnode` | `Vnode` | Yes | This method is meant to be used as or in conjunction with an `<a>` [vnode](vnodes.md)'s [`oncreate` and `onupdate` hooks](lifecycle-methods.md) | ||
**returns** | | | Returns `undefined` | ||
```JS | ||
m("a[href=/]", {oncreate: m.route.link({replace: true})}) | ||
``` | ||
`m.route.link(args)` | ||
Argument | Type | Required | Description | ||
----------------- | ---------------| -------- | --- | ||
`args` | `Vnode|Object` | Yes | This method is meant to be used as or in conjunction with an `<a>` [vnode](vnodes.md)'s [`oncreate` and `onupdate` hooks](lifecycle-methods.md) | ||
**returns** | `function` | | Returns the onclick handler function for the component | ||
##### m.route.param | ||
@@ -147,4 +153,8 @@ | ||
A RouteResolver is an object that contains an `onmatch` method and/or a `render` method. Both methods are optional, but at least one must be present. A RouteResolver is not a component, and therefore it does NOT have lifecycle methods. As a rule of thumb, RouteResolvers should be in the same file as the `m.route` call, whereas component definitions should be in their own modules. | ||
A RouteResolver is a non-component object that contains an `onmatch` method and/or a `render` method. Both methods are optional, but at least one must be present. | ||
If an object can be detected as a component (by the presence of a `view` method or by being a `function`/`class`), it will be treated as such even if it has `onmatch` or `render` methods. Since a RouteResolver is not a component, it does not have lifecycle methods. | ||
As a rule of thumb, RouteResolvers should be in the same file as the `m.route` call, whereas component definitions should be in their own modules. | ||
`routeResolver = {onmatch, render}` | ||
@@ -324,3 +334,3 @@ | ||
m.route(document.body, "/edit/pictures/image.jpg", { | ||
"/files/:file...": Edit, | ||
"/edit/:file...": Edit, | ||
}) | ||
@@ -331,3 +341,3 @@ ``` | ||
For isomorphic / universal javascript app, an url param and a variadic route combined is very usefull to display custom 404 error page. | ||
For isomorphic / universal javascript app, an url param and a variadic route combined is very useful to display custom 404 error page. | ||
@@ -478,3 +488,3 @@ In a case of 404 Not Found error, the server send back the custom page to client. When Mithril is loaded, it will redirect client to the default route because it can't know that route. | ||
Note that in this case, if the Layout component the `oninit` and `oncreate` lifecycle methods would only fire on the Layout component on the first route change (assuming all routes use the same layout). | ||
Note that in this case, if the Layout component has `oninit` and `oncreate` lifecycle methods, they would only fire on the first route change (assuming all routes use the same layout). | ||
@@ -518,3 +528,3 @@ To clarify the difference between the two examples, example 1 is equivalent to this code: | ||
The RouteResolver's `onmatch` hook can be used to run logic before the top level component in a route is initializated. The example below shows how to implement a login wall that prevents users from seeing the `/secret` page unless they login. | ||
The RouteResolver's `onmatch` hook can be used to run logic before the top level component in a route is initialized. The example below shows how to implement a login wall that prevents users from seeing the `/secret` page unless they login. | ||
@@ -579,3 +589,3 @@ ```javascript | ||
m("input[type=password]", {oninput: m.withAttr("value", Auth.setPassword), value: Auth.password}), | ||
m("button[type=button]", {onclick: Auth.login, "Login") | ||
m("button[type=button]", {onclick: Auth.login}, "Login") | ||
]) | ||
@@ -600,3 +610,3 @@ } | ||
Typically, a component can load data upon initialization. Loading data this way renders the component twice (once upon routing, and once after the request completes). | ||
Typically, a component can load data upon initialization. Loading data this way renders the component twice. The first render pass occurs upon routing, and the second fires after the request completes. Take care to note that `loadUsers()` returns a Promise, but any Promise returned by `oninit` is currently ignored. The second render pass comes from the [`background` option for `m.request`](request.md). | ||
@@ -603,0 +613,0 @@ ```javascript |
@@ -5,2 +5,4 @@ # Simple application | ||
An interactive running example can be seen here [flems: Simple Application](https://flems.io/#0=N4IgzgpgNhDGAuEAmIBcICGAHLA6AVmCADQgBmAljEagNqgB2GAthGiAKqQBOAsgPZJoBIqVj8GiSewBuGbgAIuERQF4FwADoMFuhVAph4qBbQC6xbXv38MSADKHjCsgFcGCChIAUASg1W1nrcEPCu3DrMuCEAjq4QRt5aOkGprPAAFoImmiAA4gCiACq5limp1uFQOSAZ8PBYYKgA9M0hzAC0IUYd2BS4GSr8ANau2HjizM19za48YKWBFXoA7hSZAMIhQpIUGFBNCvDc8WXLAL6+S0G4mRAM3m4e8F4P3a5Q8P7Jy9bK3LgDEYFOp3p9cEgMPAMNdrJdrucytdYOEQpITMBEdcoLYkCYnp4fBQkN9YcFQuFItEIHEEvAkmS0qEsniFLlCiUSIyglUanUGk1Wu0unTelh+oNuCMxjhcJNpuLZvNmrkFABqBTEs6-XRrTbbe4vfaHY6nbnw8o3O4PAkvHxgr4BS3Lf5y1GGkEKB3mq6WrEMa5gDAyCD49yEh6k53ksIRBRRWLxRI-HXx5nZNkgAAKHE52p1vMz-MaLTaEE63XgYolQ1G4zl-CmMzmKjAKpA6qUPDd3DR8FwWu51kh0JMrpRvcN+d+eoyW2Qhr2BxMpog07hvrh2nOIERjBYbHQ-0cRhEJBA4kkhtk8i7KhP8E9Kd0EgoDHWY+7OLsD+nMgoEArGGzyvH4TrLCEsaRN4uS4C23AdEC8ClHeAJIbgzDYI84Z2g88FRqmXoUnGzAwZgcE8IhTgdOs5YocAGQhGQNTNMg6ztp28EDkgxAKBIsAhFCobxtE-CuIggJvsMiIKFxlDcEYAByB6dqqqoalxUAYEpB6bhUlx6bo5zbruxD7qw7D-AAYvw3BRIQ56XlI8A3oo1m2cwT7XK+77OLaoEyAwggQN8rrfkg3iBcFuBQscYDcb4-rWP+gHARGYHPkEkGUvGZFkB59FDhUEhgK4ABGzAfi4OGgSF4GERUEC4FgIQhpIAAiEBkBgHz0oZDV-N2QYhn4RWpMZ0bjbxtBjbluRaWVwgLdAKG5FZFAKY+TCsLkvjrhUpG5G+WDiQODAnfAtDwAAnlgECqIgAAe8BmLQWBabAEBZFAQjcKo62bQo20QGYhWTb8PkXSYUSzgAgvU3BkXIUDxCh-k+Mj8Shd2E59rg8k6awnqYxAlz7TqJOfioPZ4wT8DKTt4MbuTQSHSAy1QICGCLVAq0gPY2lbQeu0s9YbPHadEuXe9GCfd9v2qALwLA6DJD1QNkPidDuBwwjSP7Kjavow8JPY9TuOGlzhMQMTBuk3ts3JXbVMAhbkhW-TwtM3oZOzWzZXifAEi4AH9QSFdt33aVFXrKrvG5AAysGEAi9yZj9RNO57iAwPsAL11if2DliBIzmuQo+eF15lopUB1UgRjQVCARFTZSRZGYW+XMF+JKEzd7uhs0wMgYfcrh947ehszCauZQNjFdSYADkzRIUvosQx4gmINrUriU1BgMMMk9GfHnDzLts3pxvg9kZAEYoVFQhyhkVBIGi-XWOnCImdnufoPWYuF5S7XnQAmQuTUWpdQoI9bwS8ADES9fTgP3t4JA-AUSsHdmVQQ10z6rycGDawuQCFGFyBibkaJfppVwhlWabdoKV3ErxUix4nC+E-j7BE04SFsXgM0VAxJyHqyyvcah9d0pPzqnPVuxFGEYB7vAFh3h3J2V4lImKCMwAcPNNw7cvhTLmUPCAOUYBRDAKvNIdAOCkB4LOhdYgIdA4SA0PldEQU7L7AUAARgAGxYEegoAAaioSETAADcmFuAAHM3wmAAEwAAYAkTW0N3KuwAomxIYKgbxyTAk9SDpEjAj0OhrCQJkXJiTqkBPCRNUeDBXAaCyXExJCg2kAGZ8l1O0Gk+CVFgTACQh0Iw10YCoCCgwCAxSYmtPaT47pWA7BIDfNE1AiSekMAoioAZVZaKeWAGVWWwxol7wYHieB3UrkYHCTg7g1DvEBIUGAfgBgkAKHgUgL54TxA4m4KgeBHSgXhJWWAGW11UBlRxLAYYMzsnrPmY8x64SllfNWagAAHE87xABWWpT0qxCHENwKErwJkSGmfU-pwz9moCyCGRQwACUdCJbZUlEhUDuF+ofSlvStkcw0KC8FkLoWwpaTktpbS8XIvqVLDQdyHlPJeW8j5XykC3Nsr9LodgKBzFQB02pODSlgAoAAL3RQqnZRqQWGGFVCjBYr5DwslQs2pqKVkMDWXk7F0rwnlMqXkxJABSTZTiw46EOcc05YlzkAogPGjV9yVC5KVa84kqrvmWoQiSlZeqDXIt+bZAFQKOk2rBVpCFb4eUdHtTCuFcy2neuRe69FTafG+uZaykluFyVTNDaHIOOT6UqHlVGs5FyIAYsnZOupu4LDsykjQegOcDzsEqpkbgVBzxVHYMWQUsxzonIbFMddjEqAAAFvG4Cvb45op7N2cyATdO67AHLnDMOcIAA) | ||
First let's create an entry point for the application. Create a file `index.html`: | ||
@@ -140,2 +142,3 @@ | ||
```javascript | ||
// src/views/UserList.js | ||
var m = require("mithril") | ||
@@ -544,2 +547,3 @@ var User = require("../models/User") | ||
```javascript | ||
// src/views/Layout.js | ||
var m = require("mithril") | ||
@@ -546,0 +550,0 @@ |
@@ -12,6 +12,6 @@ # stream() | ||
- [Stream["fantasy-land/of"]](#streamfantasy-landof) | ||
- [Instance members](#static-members) | ||
- [Instance members](#instance-members) | ||
- [stream.map](#streammap) | ||
- [stream.end](#streamend) | ||
- [stream["fantasy-land/of"]](#streamfantasy-landof) | ||
- [stream["fantasy-land/of"]](#streamfantasy-landof-1) | ||
- [stream["fantasy-land/map"]](#streamfantasy-landmap) | ||
@@ -163,3 +163,3 @@ - [stream["fantasy-land/ap"]](#streamfantasy-landap) | ||
`stream = stream["fantasy-land/of"](value)` | ||
`stream = Stream["fantasy-land/of"](value)` | ||
@@ -217,3 +217,3 @@ Argument | Type | Required | Description | ||
`dependentStream = stream()["fantasy-land/of"](callback)` | ||
`dependentStream = stream()["fantasy-land/map"](callback)` | ||
@@ -390,3 +390,3 @@ Argument | Type | Required | Description | ||
A stream can depend on any number of streams and it's guaranteed to update atomically. For example, if a stream A has two dependent streams B and C, and a fourth stream D is dependent on both B and C, the stream D will only update once if the value of A changes. This guarantees that the callback for stream D is never called with unstable values such as when B has a new value but C has the old value. Atomicity also bring the performance benefits of not recomputing downstreams unnecessarily. | ||
A stream can depend on any number of streams and it's guaranteed to update atomically. For example, if a stream A has two dependent streams B and C, and a fourth stream D is dependent on both B and C, the stream D will only update once if the value of A changes. This guarantees that the callback for stream D is never called with unstable values such as when B has a new value but C has the old value. Atomicity also brings the performance benefits of not recomputing downstreams unnecessarily. | ||
@@ -393,0 +393,0 @@ You can prevent dependent streams from being updated by returning the special value `stream.HALT` |
@@ -61,3 +61,3 @@ # Testing | ||
Writing tests after the fact is a way to document the behavior of a system and avoid regressions. They are useful to ensure that obscure corner cases are not inadvertedly broken and that previously fixed bugs do not get re-introduced by unrelated changes. | ||
Writing tests after the fact is a way to document the behavior of a system and avoid regressions. They are useful to ensure that obscure corner cases are not inadvertently broken and that previously fixed bugs do not get re-introduced by unrelated changes. | ||
@@ -78,3 +78,5 @@ --- | ||
view: function() { | ||
return m("div", "Hello world") | ||
return m("div", | ||
m("p", "Hello World") | ||
) | ||
} | ||
@@ -95,3 +97,3 @@ } | ||
o(vnode.children.length).equals(1) | ||
o(vnode.children[0].tag).equals("#") | ||
o(vnode.children[0].tag).equals("p") | ||
o(vnode.children[0].children).equals("Hello world") | ||
@@ -98,0 +100,0 @@ }) |
@@ -14,3 +14,3 @@ # trust(html) | ||
Turns an HTML string into unescaped HTML. **Do not use `m.trust` on unsanitized user input.** | ||
Turns an HTML or SVG string into unescaped HTML or SVG. **Do not use `m.trust` on unsanitized user input.** | ||
@@ -27,3 +27,3 @@ Always try to use an [alternative method](#avoid-trusting-html) first, before considering using `m.trust`. | ||
----------- | -------------------- | -------- | --- | ||
`html` | `String` | Yes | A string containing HTML text | ||
`html` | `String` | Yes | A string containing HTML or SVG text | ||
**returns** | `Vnode` | | A trusted HTML [vnode](vnodes.md) that represents the input string | ||
@@ -30,0 +30,0 @@ |
@@ -24,7 +24,7 @@ # Virtual DOM nodes | ||
The reason Mithril goes to such great lengths to support a rendering model that recreates the entire virtual DOM tree on every render is to provide [retained mode rendering](https://en.wikipedia.org/wiki/Retained_mode), a style of rendering that makes it drastically easier to manage UI complexity. | ||
The reason Mithril goes to such great lengths to support a rendering model that recreates the entire virtual DOM tree on every render is to provide a declarative [immediate mode](https://en.wikipedia.org/wiki/Immediate_mode_(computer_graphics)) API, a style of rendering that makes it drastically easier to manage UI complexity. | ||
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. | ||
To illustrate why immediate mode is so important, consider the DOM API and HTML. The DOM API is an imperative [retained mode](https://en.wikipedia.org/wiki/Retained_mode) API and requires 1. writing out exact instructions to assemble a DOM tree procedurally, and 2. writing out other instructions to update that tree. 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. | ||
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. | ||
In contrast, HTML is closer to an immediate 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. | ||
@@ -78,3 +78,2 @@ Virtual DOM goes one step further than HTML by allowing you to write *dynamic* DOM trees without having to manually write multiple sets of DOM API calls to efficiently synchronize the UI to arbitrary data changes. | ||
`state` | `Object?` | An object that is persisted between redraws. It is provided by the core engine when needed. In POJO component vnodes, the `state` inherits prototypically from the component object/class. In class component vnodes it is an instance of the class. In closure components it is the object returned by the closure. | ||
`_state` | `Object?` | For components, a reference to the original `vnode.state` object, used to lookup the `view` and hooks. This property is only used internally by Mithril, do not use or modify it. | ||
`events` | `Object?` | An object that is persisted between redraws and that stores event handlers so that they can be removed using the DOM API. The `events` property is `undefined` if there are no event handlers defined. This property is only used internally by Mithril, do not use or modify it. | ||
@@ -94,3 +93,3 @@ `instance` | `Object?` | For components, a storage location for the value returned by the `view`. This property is only used internally by Mithril, do not use or modify it. | ||
Element | `{tag: "div"}` | Represents a DOM element. | ||
Fragment | `{tag: "[", children: []}` | Represents a list of DOM elements whose parent DOM element may also contain other elements that are not in the fragment. When using the [`m()`](hyperscript.md) helper function, fragment vnodes can only be created by nesting arrays into the `children` parameter of `m()`. `m("[")` does not create a valid vnode. | ||
Fragment | `{tag: "[", children: []}` | Represents a list of DOM elements whose parent DOM element may also contain other elements that are not in the fragment. When using the [`m()`](hyperscript.md) helper function, fragment vnodes can only be created by nesting arrays into the `children` parameter of `m()`. `m("[")` does not create a valid vnode. | ||
Text | `{tag: "#", children: ""}` | Represents a DOM text node. | ||
@@ -97,0 +96,0 @@ Trusted HTML | `{tag: "<", children: "<br>"}` | Represents a list of DOM elements from an HTML string. |
@@ -400,2 +400,11 @@ ;(function() { | ||
} | ||
// IE9 - IE11 (at least) throw an UnspecifiedError when accessing document.activeElement when | ||
// inside an iframe. Catch and swallow this error0, and heavy-handidly return null. | ||
function activeElement() { | ||
try { | ||
return $doc.activeElement | ||
} catch (e) { | ||
return null | ||
} | ||
} | ||
//create | ||
@@ -854,9 +863,9 @@ function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) { | ||
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome | ||
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized0 && vnode.dom === $doc.activeElement) return | ||
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized0 && vnode.dom === activeElement()) return | ||
//setting select[value] to same value while having select open blinks select dropdown in Chrome | ||
if (vnode.tag === "select") { | ||
if (value === null) { | ||
if (vnode.dom.selectedIndex === -1 && vnode.dom === $doc.activeElement) return | ||
if (vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()) return | ||
} else { | ||
if (old !== null && vnode.dom.value === normalized0 && vnode.dom === $doc.activeElement) return | ||
if (old !== null && vnode.dom.value === normalized0 && vnode.dom === activeElement()) return | ||
} | ||
@@ -906,3 +915,3 @@ } | ||
function isFormAttribute(vnode, attr) { | ||
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement | ||
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === activeElement() | ||
} | ||
@@ -981,3 +990,3 @@ function isLifecycleMethod(attr) { | ||
var hooks = [] | ||
var active = $doc.activeElement | ||
var active = activeElement() | ||
var namespace = dom.namespaceURI | ||
@@ -990,3 +999,3 @@ // First time0 rendering into a node clears it out | ||
// document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement | ||
if (active != null && $doc.activeElement !== active) active.focus() | ||
if (active != null && activeElement() !== active) active.focus() | ||
for (var i = 0; i < hooks.length; i++) hooks[i]() | ||
@@ -1062,3 +1071,3 @@ } | ||
if (string.charAt(0) === "?") string = string.slice(1) | ||
var entries = string.split("&"), data0 = {}, counters = {} | ||
var entries = string.split("&"), counters = {}, data0 = {} | ||
for (var i = 0; i < entries.length; i++) { | ||
@@ -1076,12 +1085,20 @@ var entry = entries[i].split("=") | ||
var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10)) | ||
var isValue = j === levels.length - 1 | ||
if (level === "") { | ||
var key5 = levels.slice(0, j).join() | ||
if (counters[key5] == null) counters[key5] = 0 | ||
if (counters[key5] == null) { | ||
counters[key5] = Array.isArray(cursor) ? cursor.length : 0 | ||
} | ||
level = counters[key5]++ | ||
} | ||
if (cursor[level] == null) { | ||
cursor[level] = isValue ? value : isNumber ? [] : {} | ||
// Disallow direct prototype pollution | ||
else if (level === "__proto__") break | ||
if (j === levels.length - 1) cursor[level] = value | ||
else { | ||
// Read own properties exclusively to disallow indirect | ||
// prototype pollution | ||
var desc = Object.getOwnPropertyDescriptor(cursor, level) | ||
if (desc != null) desc = desc.value | ||
if (desc == null) cursor[level] = desc = isNumber ? [] : {} | ||
cursor = desc | ||
} | ||
cursor = cursor[level] | ||
} | ||
@@ -1260,3 +1277,3 @@ } | ||
m.buildQueryString = buildQueryString | ||
m.version = "1.1.6" | ||
m.version = "1.1.7" | ||
m.vnode = Vnode | ||
@@ -1263,0 +1280,0 @@ if (typeof module !== "undefined") module["exports"] = m |
@@ -1,44 +0,44 @@ | ||
(function(){function B(b,d,f,g,e,n){return{tag:b,key:d,attrs:f,children:g,text:e,dom:n,domSize:void 0,state:void 0,_state:void 0,events:void 0,instance:void 0,skip:!1}}function N(b){for(var d in b)if(G.call(b,d))return!1;return!0}function D(b){var d=arguments[1],f=2;if(null==b||"string"!==typeof b&&"function"!==typeof b&&"function"!==typeof b.view)throw Error("The selector must be either a string or a component.");if("string"===typeof b){var g;if(!(g=O[b])){var e="div";for(var n=[],h={};g=Q.exec(b);){var q= | ||
g[1],m=g[2];""===q&&""!==m?e=m:"#"===q?h.id=m:"."===q?n.push(m):"["===g[3][0]&&((q=g[6])&&(q=q.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===g[4]?n.push(q):h[g[4]]=""===q?q:q||!0)}0<n.length&&(h.className=n.join(" "));g=O[b]={tag:e,attrs:h}}}if(null==d)d={};else if("object"!==typeof d||null!=d.tag||Array.isArray(d))d={},f=1;if(arguments.length===f+1)e=arguments[f],Array.isArray(e)||(e=[e]);else for(e=[];f<arguments.length;)e.push(arguments[f++]);f=B.normalizeChildren(e);if("string"=== | ||
typeof b){e=!1;var k,t;n=d.className||d["class"];if(!N(g.attrs)&&!N(d)){h={};for(var a in d)G.call(d,a)&&(h[a]=d[a]);d=h}for(a in g.attrs)G.call(g.attrs,a)&&(d[a]=g.attrs[a]);void 0!==n&&(void 0!==d["class"]&&(d["class"]=void 0,d.className=n),null!=g.attrs.className&&(d.className=g.attrs.className+" "+n));for(a in d)if(G.call(d,a)&&"key"!==a){e=!0;break}Array.isArray(f)&&1===f.length&&null!=f[0]&&"#"===f[0].tag?t=f[0].children:k=f;return B(g.tag,d.key,e?d:void 0,k,t)}return B(b,d.key,d,f)}function R(b){var d= | ||
0,f=null,g="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var e=Date.now();0===d||16<=e-d?(d=e,b()):null===f&&(f=g(function(){f=null;b();d=Date.now()},16-(e-d)))}}B.normalize=function(b){return Array.isArray(b)?B("[",void 0,void 0,B.normalizeChildren(b),void 0,void 0):null!=b&&"object"!==typeof b?B("#",void 0,void 0,!1===b?"":b,void 0,void 0):b};B.normalizeChildren=function(b){for(var d=0;d<b.length;d++)b[d]=B.normalize(b[d]);return b};var Q=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g, | ||
O={},G={}.hasOwnProperty;D.trust=function(b){null==b&&(b="");return B("<",void 0,void 0,b,void 0,void 0)};D.fragment=function(b,d){return B("[",b.key,b,B.normalizeChildren(d),void 0,void 0)};var x=function(b){function d(b,a){return function E(d){var h;try{if(!a||null==d||"object"!==typeof d&&"function"!==typeof d||"function"!==typeof(h=d.then))k(function(){a||0!==b.length||console.error("Possible unhandled promise rejection:",d);for(var f=0;f<b.length;f++)b[f](d);e.length=0;n.length=0;m.state=a;m.retry= | ||
function(){E(d)}});else{if(d===g)throw new TypeError("Promise can't be resolved w/ itself");f(h.bind(d))}}catch(S){q(S)}}}function f(b){function a(a){return function(b){0<d++||a(b)}}var d=0,f=a(q);try{b(a(h),f)}catch(E){f(E)}}if(!(this instanceof x))throw Error("Promise must be called with `new`");if("function"!==typeof b)throw new TypeError("executor must be a function");var g=this,e=[],n=[],h=d(e,!0),q=d(n,!1),m=g._instance={resolvers:e,rejectors:n},k="function"===typeof setImmediate?setImmediate: | ||
setTimeout;f(b)};x.prototype.then=function(b,d){function f(b,d,f,h){d.push(function(a){if("function"!==typeof b)f(a);else try{e(b(a))}catch(w){n&&n(w)}});"function"===typeof g.retry&&h===g.state&&g.retry()}var g=this._instance,e,n,h=new x(function(b,d){e=b;n=d});f(b,g.resolvers,e,!0);f(d,g.rejectors,n,!1);return h};x.prototype["catch"]=function(b){return this.then(null,b)};x.resolve=function(b){return b instanceof x?b:new x(function(d){d(b)})};x.reject=function(b){return new x(function(d,f){f(b)})}; | ||
x.all=function(b){return new x(function(d,f){var g=b.length,e=0,n=[];if(0===b.length)d([]);else for(var h=0;h<b.length;h++)(function(h){function m(b){e++;n[h]=b;e===g&&d(n)}null==b[h]||"object"!==typeof b[h]&&"function"!==typeof b[h]||"function"!==typeof b[h].then?m(b[h]):b[h].then(m,f)})(h)})};x.race=function(b){return new x(function(d,f){for(var g=0;g<b.length;g++)b[g].then(d,f)})};"undefined"!==typeof window?("undefined"===typeof window.Promise&&(window.Promise=x),x=window.Promise):"undefined"!== | ||
typeof global&&("undefined"===typeof global.Promise&&(global.Promise=x),x=global.Promise);var F=function(b){function d(b,g){if(Array.isArray(g))for(var e=0;e<g.length;e++)d(b+"["+e+"]",g[e]);else if("[object Object]"===Object.prototype.toString.call(g))for(e in g)d(b+"["+e+"]",g[e]);else f.push(encodeURIComponent(b)+(null!=g&&""!==g?"="+encodeURIComponent(g):""))}if("[object Object]"!==Object.prototype.toString.call(b))return"";var f=[],g;for(g in b)d(g,b[g]);return f.join("&")},T=/^file:\/\//i,L= | ||
function(b,d){function f(){function a(){0===--b&&"function"===typeof t&&t()}var b=0;return function u(d){var f=d.then;d.then=function(){b++;var e=f.apply(d,arguments);e.then(a,function(d){a();if(0===b)throw d;});return u(e)};return d}}function g(a,b){if("string"===typeof a){var d=a;a=b||{};null==a.url&&(a.url=d)}return a}function e(a,b){if(null==b)return a;for(var d=a.match(/:[^\/]+/gi)||[],f=0;f<d.length;f++){var e=d[f].slice(1);null!=b[e]&&(a=a.replace(d[f],b[e]))}return a}function n(a,b){var d= | ||
F(b);if(""!==d){var f=0>a.indexOf("?")?"?":"&";a+=f+d}return a}function h(a){try{return""!==a?JSON.parse(a):null}catch(w){throw Error(a);}}function q(a){return a.responseText}function m(a,b){if("function"===typeof a)if(Array.isArray(b))for(var d=0;d<b.length;d++)b[d]=new a(b[d]);else return new a(b);return b}var k=0,t;return{request:function(a,k){var t=f();a=g(a,k);var w=new d(function(d,f){null==a.method&&(a.method="GET");a.method=a.method.toUpperCase();var g="GET"===a.method||"TRACE"===a.method? | ||
!1:"boolean"===typeof a.useBody?a.useBody:!0;"function"!==typeof a.serialize&&(a.serialize="undefined"!==typeof FormData&&a.data instanceof FormData?function(a){return a}:JSON.stringify);"function"!==typeof a.deserialize&&(a.deserialize=h);"function"!==typeof a.extract&&(a.extract=q);a.url=e(a.url,a.data);g?a.data=a.serialize(a.data):a.url=n(a.url,a.data);var k=new b.XMLHttpRequest,t=!1,w=k.abort;k.abort=function(){t=!0;w.call(k)};k.open(a.method,a.url,"boolean"===typeof a.async?a.async:!0,"string"=== | ||
typeof a.user?a.user:void 0,"string"===typeof a.password?a.password:void 0);a.serialize!==JSON.stringify||!g||a.headers&&a.headers.hasOwnProperty("Content-Type")||k.setRequestHeader("Content-Type","application/json; charset=utf-8");a.deserialize!==h||a.headers&&a.headers.hasOwnProperty("Accept")||k.setRequestHeader("Accept","application/json, text/*");a.withCredentials&&(k.withCredentials=a.withCredentials);for(var u in a.headers)({}).hasOwnProperty.call(a.headers,u)&&k.setRequestHeader(u,a.headers[u]); | ||
"function"===typeof a.config&&(k=a.config(k,a)||k);k.onreadystatechange=function(){if(!t&&4===k.readyState)try{var b=a.extract!==q?a.extract(k,a):a.deserialize(a.extract(k,a));if(200<=k.status&&300>k.status||304===k.status||T.test(a.url))d(m(a.type,b));else{var l=Error(k.responseText),c;for(c in b)l[c]=b[c];f(l)}}catch(p){f(p)}};g&&null!=a.data?k.send(a.data):k.send()});return!0===a.background?w:t(w)},jsonp:function(a,h){var t=f();a=g(a,h);var q=new d(function(d,f){var g=a.callbackName||"_mithril_"+ | ||
Math.round(1E16*Math.random())+"_"+k++,h=b.document.createElement("script");b[g]=function(f){h.parentNode.removeChild(h);d(m(a.type,f));delete b[g]};h.onerror=function(){h.parentNode.removeChild(h);f(Error("JSONP request failed"));delete b[g]};null==a.data&&(a.data={});a.url=e(a.url,a.data);a.data[a.callbackKey||"callback"]=g;h.src=n(a.url,a.data);b.document.documentElement.appendChild(h)});return!0===a.background?q:t(q)},setCompletionCallback:function(a){t=a}}}(window,x),P=function(b){function d(l, | ||
c,p,a,b,d,g){for(;p<a;p++){var v=c[p];null!=v&&f(l,v,b,g,d)}}function f(l,c,p,a,b){var v=c.tag;if("string"===typeof v)switch(c.state={},null!=c.attrs&&D(c.attrs,c,p),v){case "#":return c.dom=A.createTextNode(c.children),k(l,c.dom,b),c.dom;case "<":return g(l,c,b);case "[":var h=A.createDocumentFragment();null!=c.children&&(v=c.children,d(h,v,0,v.length,p,null,a));c.dom=h.firstChild;c.domSize=h.childNodes.length;k(l,h,b);return h;default:var m=c.tag,r=(v=c.attrs)&&v.is;m=(a=c.attrs&&c.attrs.xmlns|| | ||
G[c.tag]||a)?r?A.createElementNS(a,m,{is:r}):A.createElementNS(a,m):r?A.createElement(m,{is:r}):A.createElement(m);c.dom=m;if(null!=v)for(h in r=a,v)E(c,h,null,v[h],r);k(l,m,b);null!=c.attrs&&null!=c.attrs.contenteditable?t(c):(null!=c.text&&(""!==c.text?m.textContent=c.text:c.children=[B("#",void 0,void 0,c.text,void 0,void 0)]),null!=c.children&&(l=c.children,d(m,l,0,l.length,p,null,a),l=c.attrs,"select"===c.tag&&null!=l&&("value"in l&&E(c,"value",null,l.value,void 0),"selectedIndex"in l&&E(c,"selectedIndex", | ||
null,l.selectedIndex,void 0))));return m}else return e(c,p),null!=c.instance?(p=f(l,c.instance,p,a,b),c.dom=c.instance.dom,c.domSize=null!=c.dom?c.instance.domSize:0,k(l,p,b),c=p):(c.domSize=0,c=K),c}function g(l,c,a){var p={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";p=A.createElement(p);p.innerHTML=c.children;c.dom=p.firstChild;c.domSize=p.childNodes.length;c=A.createDocumentFragment(); | ||
for(var b;b=p.firstChild;)c.appendChild(b);k(l,c,a);return c}function e(l,c){if("function"===typeof l.tag.view){l.state=Object.create(l.tag);var a=l.state.view;if(null!=a.$$reentrantLock$$)return K;a.$$reentrantLock$$=!0}else{l.state=void 0;a=l.tag;if(null!=a.$$reentrantLock$$)return K;a.$$reentrantLock$$=!0;l.state=null!=l.tag.prototype&&"function"===typeof l.tag.prototype.view?new l.tag(l):l.tag(l)}l._state=l.state;null!=l.attrs&&D(l.attrs,l,c);D(l._state,l,c);l.instance=B.normalize(l._state.view.call(l.state, | ||
l));if(l.instance===l)throw Error("A view cannot return the vnode it received as argument");a.$$reentrantLock$$=null}function n(l,c,p,b,g,e,n){if(c!==p&&(null!=c||null!=p))if(null==c)d(l,p,0,p.length,g,e,n);else if(null==p)a(c,0,c.length,p);else{if(c.length===p.length){for(var v=!1,r=0;r<p.length;r++)if(null!=p[r]&&null!=c[r]){v=null==p[r].key&&null==c[r].key;break}if(v){for(r=0;r<c.length;r++)c[r]!==p[r]&&(null==c[r]&&null!=p[r]?f(l,p[r],g,n,m(c,r+1,e)):null==p[r]?a(c,r,r+1,p):h(l,c[r],p[r],g,m(c, | ||
r+1,e),b,n));return}}if(!b)a:{if(null!=c.pool&&Math.abs(c.pool.length-p.length)<=Math.abs(c.length-p.length)&&(b=p[0]&&p[0].children&&p[0].children.length||0,Math.abs((c.pool[0]&&c.pool[0].children&&c.pool[0].children.length||0)-b)<=Math.abs((c[0]&&c[0].children&&c[0].children.length||0)-b))){b=!0;break a}b=!1}if(b){var t=c.pool;c=c.concat(c.pool)}r=v=0;for(var w=c.length-1,y=p.length-1,H;w>=v&&y>=r;){var u=c[v],z=p[r];if(u!==z||b)if(null==u)v++;else if(null==z)r++;else if(u.key===z.key){var C=null!= | ||
t&&v>=c.length-t.length||null==t&&b;v++;r++;h(l,u,z,g,m(c,v,e),C,n);b&&u.tag===z.tag&&k(l,q(u),e)}else if(u=c[w],u!==z||b)if(null==u)w--;else if(null==z)r++;else if(u.key===z.key)C=null!=t&&w>=c.length-t.length||null==t&&b,h(l,u,z,g,m(c,w+1,e),C,n),(b||r<y)&&k(l,q(u),m(c,v,e)),w--,r++;else break;else w--,r++;else v++,r++}for(;w>=v&&y>=r;){u=c[w];z=p[y];if(u!==z||b)if(null==u)w--;else{if(null!=z)if(u.key===z.key)C=null!=t&&w>=c.length-t.length||null==t&&b,h(l,u,z,g,m(c,w+1,e),C,n),b&&u.tag===z.tag&& | ||
k(l,q(u),e),null!=u.dom&&(e=u.dom),w--;else{if(!H){H=c;u=w;C={};var A;for(A=0;A<u;A++){var x=H[A];null!=x&&(x=x.key,null!=x&&(C[x]=A))}H=C}null!=z&&(u=H[z.key],null!=u?(C=c[u],h(l,C,z,g,m(c,w+1,e),b,n),k(l,q(C),e),c[u].skip=!0,null!=C.dom&&(e=C.dom)):e=f(l,z,g,n,e))}y--}else w--,y--;if(y<r)break}d(l,p,r,y+1,g,e,n);a(c,v,w+1,p)}}function h(l,c,a,b,d,m,k){var p=c.tag;if(p===a.tag){a.state=c.state;a._state=c._state;a.events=c.events;var v;if(v=!m){var C,z;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&& | ||
(C=a.attrs.onbeforeupdate.call(a.state,a,c));"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeupdate&&(z=a._state.onbeforeupdate.call(a.state,a,c));void 0===C&&void 0===z||C||z?v=!1:(a.dom=c.dom,a.domSize=c.domSize,a.instance=c.instance,v=!0)}if(!v)if("string"===typeof p)switch(null!=a.attrs&&(m?(a.state={},D(a.attrs,a,b)):J(a.attrs,a,b)),p){case "#":c.children.toString()!==a.children.toString()&&(c.dom.nodeValue=a.children);a.dom=c.dom;break;case "<":c.children!==a.children?(q(c),g(l, | ||
a,d)):(a.dom=c.dom,a.domSize=c.domSize);break;case "[":n(l,c.children,a.children,m,b,d,k);c=0;b=a.children;a.dom=null;if(null!=b){for(m=0;m<b.length;m++){var y=b[m];null!=y&&null!=y.dom&&(null==a.dom&&(a.dom=y.dom),c+=y.domSize||1)}1!==c&&(a.domSize=c)}break;default:l=a.dom=c.dom;k=a.attrs&&a.attrs.xmlns||G[a.tag]||k;"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));d=c.attrs;p=a.attrs;v=k;if(null!=p)for(y in p)E(a,y,d&&d[y],p[y],v);if(null!=d)for(y in d)null!= | ||
p&&y in p||("className"===y&&(y="class"),"o"!==y[0]||"n"!==y[1]||u(y)?"key"!==y&&a.dom.removeAttribute(y):x(a,y,void 0));null!=a.attrs&&null!=a.attrs.contenteditable?t(a):null!=c.text&&null!=a.text&&""!==a.text?c.text.toString()!==a.text.toString()&&(c.dom.firstChild.nodeValue=a.text):(null!=c.text&&(c.children=[B("#",void 0,void 0,c.text,void 0,c.dom.firstChild)]),null!=a.text&&(a.children=[B("#",void 0,void 0,a.text,void 0,void 0)]),n(l,c.children,a.children,m,b,null,k))}else{if(m)e(a,b);else{a.instance= | ||
B.normalize(a._state.view.call(a.state,a));if(a.instance===a)throw Error("A view cannot return the vnode it received as argument");null!=a.attrs&&J(a.attrs,a,b);J(a._state,a,b)}null!=a.instance?(null==c.instance?f(l,a.instance,b,k,d):h(l,c.instance,a.instance,b,d,m,k),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=c.instance?(w(c.instance,null),a.dom=void 0,a.domSize=0):(a.dom=c.dom,a.domSize=c.domSize)}}else w(c,null),f(l,a,b,k,d)}function q(a){var c=a.domSize;if(null!=c||null==a.dom){var b= | ||
A.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 k(a,c,b){b&&b.parentNode?a.insertBefore(c,b):a.appendChild(c)}function t(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 a(a,c,b,d){for(;c<b;c++){var l=a[c];null!=l&&(l.skip?l.skip=!1:w(l,d))}}function w(a,c){function b(){if(++d===l&&(C(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var g=e.nextSibling,f=g.parentNode;null!=f&&f.removeChild(g)}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 l=1,d=0;if(a.attrs&&"function"=== | ||
typeof a.attrs.onbeforeremove){var e=a.attrs.onbeforeremove.call(a.state,a);null!=e&&"function"===typeof e.then&&(l++,e.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeremove&&(e=a._state.onbeforeremove.call(a.state,a),null!=e&&"function"===typeof e.then&&(l++,e.then(b,b)));b()}function C(a){a.attrs&&"function"===typeof a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag)"function"===typeof a._state.onremove&&a._state.onremove.call(a.state,a),null!= | ||
a.instance&&C(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&C(b)}}function E(a,b,d,e,g){var c=a.dom;if("key"!==b&&"is"!==b&&(d!==e||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===A.activeElement||"object"===typeof e)&&"undefined"!==typeof e&&!u(b)){var l=b.indexOf(":");if(-1<l&&"xlink"===b.substr(0,l))c.setAttributeNS("http://www.w3.org/1999/xlink",b.slice(l+1),e);else if("o"===b[0]&&"n"===b[1]&&"function"===typeof e)x(a, | ||
b,e);else if("style"===b)if(a=d,a===e&&(c.style.cssText="",a=null),null==e)c.style.cssText="";else if("string"===typeof e)c.style.cssText=e;else{"string"===typeof a&&(c.style.cssText="");for(var f in e)c.style[f]=e[f];if(null!=a&&"string"!==typeof a)for(f in a)f in e||(c.style[f]="")}else if(b in c&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===g&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===b){f=""+e;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===f&&a.dom=== | ||
A.activeElement)return;if("select"===a.tag)if(null===e){if(-1===a.dom.selectedIndex&&a.dom===A.activeElement)return}else if(null!==d&&a.dom.value===f&&a.dom===A.activeElement)return;if("option"===a.tag&&null!=d&&a.dom.value===f)return}"input"===a.tag&&"type"===b?c.setAttribute(b,e):c[b]=e}else"boolean"===typeof e?e?c.setAttribute(b,""):c.removeAttribute(b):c.setAttribute("className"===b?"class":b,e)}}function u(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"=== | ||
a||"onbeforeupdate"===a}function x(a,b,d){var c=a.dom,e="function"!==typeof F?d:function(a){var b=d.call(c,a);F.call(c,a);return b};if(b in c)c[b]="function"===typeof d?e:null;else{var f=b.slice(2);void 0===a.events&&(a.events={});a.events[b]!==e&&(null!=a.events[b]&&c.removeEventListener(f,a.events[b],!1),"function"===typeof d&&(a.events[b]=e,c.addEventListener(f,a.events[b],!1)))}}function D(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 J(a,b,d){"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,b))}var A=b.document,K=A.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},F;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=A.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);n(a,a.vnodes,B.normalizeChildren(b),!1,c,null,"http://www.w3.org/1999/xhtml"=== | ||
e?void 0:e);a.vnodes=b;null!=d&&A.activeElement!==d&&d.focus();for(d=0;d<c.length;d++)c[d]()},setEventCallback:function(a){return F=a}}},I=function(b){function d(b){b=g.indexOf(b);-1<b&&g.splice(b,2)}function f(){for(var b=1;b<g.length;b+=2)g[b]()}b=P(b);b.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:f()});var g=[];return{subscribe:function(b,f){d(b);g.push(b,R(f))},unsubscribe:d,redraw:f,render:b.render}}(window);L.setCompletionCallback(I.redraw);D.mount=function(b){return function(d, | ||
f){if(null===f)b.render(d,[]),b.unsubscribe(d);else{if(null==f.view&&"function"!==typeof f)throw Error("m.mount(element, component) expects a component, not a vnode");b.subscribe(d,function(){b.render(d,B(f))});b.redraw()}}}(I);var U=x,M=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},f={},g=0;g<b.length;g++){var e=b[g].split("="),n=decodeURIComponent(e[0]);e=2===e.length?decodeURIComponent(e[1]):"";"true"===e?e=!0:"false"===e&&(e=!1);var h=n.split(/\]\[?|\[/), | ||
q=d;-1<n.indexOf("[")&&h.pop();for(var m=0;m<h.length;m++){n=h[m];var k=h[m+1];k=""==k||!isNaN(parseInt(k,10));var t=m===h.length-1;""===n&&(n=h.slice(0,m).join(),null==f[n]&&(f[n]=0),n=f[n]++);null==q[n]&&(q[n]=t?e:k?[]:{});q=q[n]}}return d},V=function(b){function d(d){var e=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function f(b){return function(){null==h&&(h=n(function(){h=null;b()}))}}function g(b,d,e){var a=b.indexOf("?"), | ||
f=b.indexOf("#"),g=-1<a?a:-1<f?f:b.length;if(-1<a){a=M(b.slice(a+1,-1<f?f:b.length));for(var h in a)d[h]=a[h]}if(-1<f)for(h in d=M(b.slice(f+1)),d)e[h]=d[h];return b.slice(0,g)}var e="function"===typeof b.history.pushState,n="function"===typeof setImmediate?setImmediate:setTimeout,h,q={prefix:"#!",getPath:function(){switch(q.prefix.charAt(0)){case "#":return d("hash").slice(q.prefix.length);case "?":return d("search").slice(q.prefix.length)+d("hash");default:return d("pathname").slice(q.prefix.length)+ | ||
d("search")+d("hash")}},setPath:function(d,f,h){var a={},k={};d=g(d,a,k);if(null!=f){for(var m in f)a[m]=f[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return f[d]})}(m=F(a))&&(d+="?"+m);(k=F(k))&&(d+="#"+k);e?(k=h?h.state:null,m=h?h.title:null,b.onpopstate(),h&&h.replace?b.history.replaceState(k,m,q.prefix+d):b.history.pushState(k,m,q.prefix+d)):b.location.href=q.prefix+d},defineRoutes:function(d,h,n){function a(){var a=q.getPath(),e={},f=g(a,e,e),k=b.history.state;if(null!=k)for(var m in k)e[m]= | ||
k[m];for(var t in d)if(k=new RegExp("^"+t.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),k.test(f)){f.replace(k,function(){for(var b=t.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,1,-2),g=0;g<b.length;g++)e[b[g].replace(/:|\./g,"")]=decodeURIComponent(f[g]);h(d[t],e,a,t)});return}n(a,e)}e?b.onpopstate=f(a):"#"===q.prefix.charAt(0)&&(b.onhashchange=a);a()}};return q};D.route=function(b,d){var f=V(b),g=function(b){return b},e,n,h,q,m,k=function(b,a,k){if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined"); | ||
var t=function(){null!=e&&d.render(b,e(B(n,h.key,h)))},w=function(b){if(b!==a)f.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};f.defineRoutes(k,function(a,b,d){var f=m=function(a,k){f===m&&(n=null==k||"function"!==typeof k.view&&"function"!==typeof k?"div":k,h=b,q=d,m=null,e=(a.render||g).bind(a),t())};a.view||"function"===typeof a?f({},a):a.onmatch?U.resolve(a.onmatch(b,d)).then(function(b){f(a,b)},w):f(a,"div")},w);d.subscribe(b,t)};k.set=function(b,a,d){null!= | ||
m&&(d=d||{},d.replace=!0);m=null;f.setPath(b,a,d)};k.get=function(){return q};k.prefix=function(b){f.prefix=b};k.link=function(b){b.dom.setAttribute("href",f.prefix+b.attrs.href);b.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(f.prefix)&&(a=a.slice(f.prefix.length)),k.set(a,void 0,void 0))}};k.param=function(b){return"undefined"!==typeof h&&"undefined"!==typeof b?h[b]:h};return k}(window,I);D.withAttr= | ||
function(b,d,f){return function(g){d.call(f||this,b in g.currentTarget?g.currentTarget[b]:g.currentTarget.getAttribute(b))}};var W=P(window);D.render=W.render;D.redraw=I.redraw;D.request=L.request;D.jsonp=L.jsonp;D.parseQueryString=M;D.buildQueryString=F;D.version="1.1.6";D.vnode=B;"undefined"!==typeof module?module.exports=D:window.m=D})(); | ||
(function(){function w(a,c,g,f,e,m){return{tag:a,key:c,attrs:g,children:f,text:e,dom:m,domSize:void 0,state:void 0,_state:void 0,events:void 0,instance:void 0,skip:!1}}function O(a){for(var c in a)if(E.call(a,c))return!1;return!0}function A(a){var c=arguments[1],g=2;if(null==a||"string"!==typeof a&&"function"!==typeof a&&"function"!==typeof a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a){var f;if(!(f=P[a])){var e="div";for(var m=[],l={};f=R.exec(a);){var n= | ||
f[1],r=f[2];""===n&&""!==r?e=r:"#"===n?l.id=r:"."===n?m.push(r):"["===f[3][0]&&((n=f[6])&&(n=n.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")),"class"===f[4]?m.push(n):l[f[4]]=""===n?n:n||!0)}0<m.length&&(l.className=m.join(" "));f=P[a]={tag:e,attrs:l}}}if(null==c)c={};else if("object"!==typeof c||null!=c.tag||Array.isArray(c))c={},g=1;if(arguments.length===g+1)e=arguments[g],Array.isArray(e)||(e=[e]);else for(e=[];g<arguments.length;)e.push(arguments[g++]);g=w.normalizeChildren(e);if("string"=== | ||
typeof a){e=!1;var q,h;m=c.className||c["class"];if(!O(f.attrs)&&!O(c)){l={};for(var b in c)E.call(c,b)&&(l[b]=c[b]);c=l}for(b in f.attrs)E.call(f.attrs,b)&&(c[b]=f.attrs[b]);void 0!==m&&(void 0!==c["class"]&&(c["class"]=void 0,c.className=m),null!=f.attrs.className&&(c.className=f.attrs.className+" "+m));for(b in c)if(E.call(c,b)&&"key"!==b){e=!0;break}Array.isArray(g)&&1===g.length&&null!=g[0]&&"#"===g[0].tag?h=g[0].children:q=g;return w(f.tag,c.key,e?c:void 0,q,h)}return w(a,c.key,c,g)}function S(a){var c= | ||
0,g=null,f="function"===typeof requestAnimationFrame?requestAnimationFrame:setTimeout;return function(){var e=Date.now();0===c||16<=e-c?(c=e,a()):null===g&&(g=f(function(){g=null;a();c=Date.now()},16-(e-c)))}}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 c=0;c<a.length;c++)a[c]=w.normalize(a[c]);return a};var R=/(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g, | ||
P={},E={}.hasOwnProperty;A.trust=function(a){null==a&&(a="");return w("<",void 0,void 0,a,void 0,void 0)};A.fragment=function(a,c){return w("[",a.key,a,w.normalizeChildren(c),void 0,void 0)};var v=function(a){function c(a,b){return function G(c){var h;try{if(!b||null==c||"object"!==typeof c&&"function"!==typeof c||"function"!==typeof(h=c.then))q(function(){b||0!==a.length||console.error("Possible unhandled promise rejection:",c);for(var f=0;f<a.length;f++)a[f](c);e.length=0;m.length=0;r.state=b;r.retry= | ||
function(){G(c)}});else{if(c===f)throw new TypeError("Promise can't be resolved w/ itself");g(h.bind(c))}}catch(T){n(T)}}}function g(a){function b(b){return function(a){0<c++||b(a)}}var c=0,f=b(n);try{a(b(l),f)}catch(G){f(G)}}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,e=[],m=[],l=c(e,!0),n=c(m,!1),r=f._instance={resolvers:e,rejectors:m},q="function"===typeof setImmediate?setImmediate: | ||
setTimeout;g(a)};v.prototype.then=function(a,c){function g(a,c,g,h){c.push(function(b){if("function"!==typeof a)g(b);else try{e(a(b))}catch(C){m&&m(C)}});"function"===typeof f.retry&&h===f.state&&f.retry()}var f=this._instance,e,m,l=new v(function(a,c){e=a;m=c});g(a,f.resolvers,e,!0);g(c,f.rejectors,m,!1);return l};v.prototype["catch"]=function(a){return this.then(null,a)};v.resolve=function(a){return a instanceof v?a:new v(function(c){c(a)})};v.reject=function(a){return new v(function(c,g){g(a)})}; | ||
v.all=function(a){return new v(function(c,g){var f=a.length,e=0,m=[];if(0===a.length)c([]);else for(var l=0;l<a.length;l++)(function(n){function r(a){e++;m[n]=a;e===f&&c(m)}null==a[n]||"object"!==typeof a[n]&&"function"!==typeof a[n]||"function"!==typeof a[n].then?r(a[n]):a[n].then(r,g)})(l)})};v.race=function(a){return new v(function(c,g){for(var f=0;f<a.length;f++)a[f].then(c,g)})};"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 H=function(a){function c(a,f){if(Array.isArray(f))for(var e=0;e<f.length;e++)c(a+"["+e+"]",f[e]);else if("[object Object]"===Object.prototype.toString.call(f))for(e in f)c(a+"["+e+"]",f[e]);else g.push(encodeURIComponent(a)+(null!=f&&""!==f?"="+encodeURIComponent(f):""))}if("[object Object]"!==Object.prototype.toString.call(a))return"";var g=[],f;for(f in a)c(f,a[f]);return g.join("&")},U=/^file:\/\//i,M= | ||
function(a,c){function g(){function b(){0===--a&&"function"===typeof h&&h()}var a=0;return function z(c){var f=c.then;c.then=function(){a++;var e=f.apply(c,arguments);e.then(b,function(c){b();if(0===a)throw c;});return z(e)};return c}}function f(b,a){if("string"===typeof b){var c=b;b=a||{};null==b.url&&(b.url=c)}return b}function e(b,a){if(null==a)return b;for(var c=b.match(/:[^\/]+/gi)||[],f=0;f<c.length;f++){var e=c[f].slice(1);null!=a[e]&&(b=b.replace(c[f],a[e]))}return b}function m(b,a){var c= | ||
H(a);if(""!==c){var f=0>b.indexOf("?")?"?":"&";b+=f+c}return b}function l(b){try{return""!==b?JSON.parse(b):null}catch(C){throw Error(b);}}function n(b){return b.responseText}function r(b,a){if("function"===typeof b)if(Array.isArray(a))for(var c=0;c<a.length;c++)a[c]=new b(a[c]);else return new b(a);return a}var q=0,h;return{request:function(b,h){var q=g();b=f(b,h);var C=new c(function(c,f){null==b.method&&(b.method="GET");b.method=b.method.toUpperCase();var g="GET"===b.method||"TRACE"===b.method? | ||
!1:"boolean"===typeof b.useBody?b.useBody:!0;"function"!==typeof b.serialize&&(b.serialize="undefined"!==typeof FormData&&b.data instanceof FormData?function(b){return b}:JSON.stringify);"function"!==typeof b.deserialize&&(b.deserialize=l);"function"!==typeof b.extract&&(b.extract=n);b.url=e(b.url,b.data);g?b.data=b.serialize(b.data):b.url=m(b.url,b.data);var h=new a.XMLHttpRequest,q=!1,C=h.abort;h.abort=function(){q=!0;C.call(h)};h.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||!g||b.headers&&b.headers.hasOwnProperty("Content-Type")||h.setRequestHeader("Content-Type","application/json; charset=utf-8");b.deserialize!==l||b.headers&&b.headers.hasOwnProperty("Accept")||h.setRequestHeader("Accept","application/json, text/*");b.withCredentials&&(h.withCredentials=b.withCredentials);for(var z in b.headers)({}).hasOwnProperty.call(b.headers,z)&&h.setRequestHeader(z,b.headers[z]); | ||
"function"===typeof b.config&&(h=b.config(h,b)||h);h.onreadystatechange=function(){if(!q&&4===h.readyState)try{var a=b.extract!==n?b.extract(h,b):b.deserialize(b.extract(h,b));if(200<=h.status&&300>h.status||304===h.status||U.test(b.url))c(r(b.type,a));else{var e=Error(h.responseText),k;for(k in a)e[k]=a[k];f(e)}}catch(d){f(d)}};g&&null!=b.data?h.send(b.data):h.send()});return!0===b.background?C:q(C)},jsonp:function(b,h){var n=g();b=f(b,h);var l=new c(function(c,f){var h=b.callbackName||"_mithril_"+ | ||
Math.round(1E16*Math.random())+"_"+q++,g=a.document.createElement("script");a[h]=function(f){g.parentNode.removeChild(g);c(r(b.type,f));delete a[h]};g.onerror=function(){g.parentNode.removeChild(g);f(Error("JSONP request failed"));delete a[h]};null==b.data&&(b.data={});b.url=e(b.url,b.data);b.data[b.callbackKey||"callback"]=h;g.src=m(b.url,b.data);a.document.documentElement.appendChild(g)});return!0===b.background?l:n(l)},setCompletionCallback:function(b){h=b}}}(window,v),Q=function(a){function c(){try{return D.activeElement}catch(k){return null}} | ||
function g(k,d,u,b,a,c,h){for(;u<b;u++){var p=d[u];null!=p&&f(k,p,a,h,c)}}function f(k,d,u,a,c){var p=d.tag;if("string"===typeof p)switch(d.state={},null!=d.attrs&&K(d.attrs,d,u),p){case "#":return d.dom=D.createTextNode(d.children),h(k,d.dom,c),d.dom;case "<":return e(k,d,c);case "[":var r=D.createDocumentFragment();null!=d.children&&(p=d.children,g(r,p,0,p.length,u,null,a));d.dom=r.firstChild;d.domSize=r.childNodes.length;h(k,r,c);return r;default:var n=d.tag,I=(p=d.attrs)&&p.is;n=(a=d.attrs&&d.attrs.xmlns|| | ||
H[d.tag]||a)?I?D.createElementNS(a,n,{is:I}):D.createElementNS(a,n):I?D.createElement(n,{is:I}):D.createElement(n);d.dom=n;if(null!=p)for(r in I=a,p)z(d,r,null,p[r],I);h(k,n,c);null!=d.attrs&&null!=d.attrs.contenteditable?b(d):(null!=d.text&&(""!==d.text?n.textContent=d.text:d.children=[w("#",void 0,void 0,d.text,void 0,void 0)]),null!=d.children&&(k=d.children,g(n,k,0,k.length,u,null,a),k=d.attrs,"select"===d.tag&&null!=k&&("value"in k&&z(d,"value",null,k.value,void 0),"selectedIndex"in k&&z(d,"selectedIndex", | ||
null,k.selectedIndex,void 0))));return n}else return m(d,u),null!=d.instance?(u=f(k,d.instance,u,a,c),d.dom=d.instance.dom,d.domSize=null!=d.dom?d.instance.domSize:0,h(k,u,c),d=u):(d.domSize=0,d=E),d}function e(k,d,u){var b={caption:"table",thead:"table",tbody:"table",tfoot:"table",tr:"tbody",th:"tr",td:"tr",colgroup:"table",col:"colgroup"}[(d.children.match(/^\s*?<(\w+)/im)||[])[1]]||"div";b=D.createElement(b);b.innerHTML=d.children;d.dom=b.firstChild;d.domSize=b.childNodes.length;d=D.createDocumentFragment(); | ||
for(var a;a=b.firstChild;)d.appendChild(a);h(k,d,u);return d}function m(k,d){if("function"===typeof k.tag.view){k.state=Object.create(k.tag);var b=k.state.view;if(null!=b.$$reentrantLock$$)return E;b.$$reentrantLock$$=!0}else{k.state=void 0;b=k.tag;if(null!=b.$$reentrantLock$$)return E;b.$$reentrantLock$$=!0;k.state=null!=k.tag.prototype&&"function"===typeof k.tag.prototype.view?new k.tag(k):k.tag(k)}k._state=k.state;null!=k.attrs&&K(k.attrs,k,d);K(k._state,k,d);k.instance=w.normalize(k._state.view.call(k.state, | ||
k));if(k.instance===k)throw Error("A view cannot return the vnode it received as argument");b.$$reentrantLock$$=null}function l(k,d,b,a,c,e,m){if(d!==b&&(null!=d||null!=b))if(null==d)g(k,b,0,b.length,c,e,m);else if(null==b)C(d,0,d.length,b);else{if(d.length===b.length){for(var u=!1,p=0;p<b.length;p++)if(null!=b[p]&&null!=d[p]){u=null==b[p].key&&null==d[p].key;break}if(u){for(p=0;p<d.length;p++)d[p]!==b[p]&&(null==d[p]&&null!=b[p]?f(k,b[p],c,m,q(d,p+1,e)):null==b[p]?C(d,p,p+1,b):n(k,d[p],b[p],c,q(d, | ||
p+1,e),a,m));return}}if(!a)a:{if(null!=d.pool&&Math.abs(d.pool.length-b.length)<=Math.abs(d.length-b.length)&&(a=b[0]&&b[0].children&&b[0].children.length||0,Math.abs((d.pool[0]&&d.pool[0].children&&d.pool[0].children.length||0)-a)<=Math.abs((d[0]&&d[0].children&&d[0].children.length||0)-a))){a=!0;break a}a=!1}if(a){var l=d.pool;d=d.concat(d.pool)}p=u=0;for(var y=d.length-1,z=b.length-1,J;y>=u&&z>=p;){var x=d[u],t=b[p];if(x!==t||a)if(null==x)u++;else if(null==t)p++;else if(x.key===t.key){var B=null!= | ||
l&&u>=d.length-l.length||null==l&&a;u++;p++;n(k,x,t,c,q(d,u,e),B,m);a&&x.tag===t.tag&&h(k,r(x),e)}else if(x=d[y],x!==t||a)if(null==x)y--;else if(null==t)p++;else if(x.key===t.key)B=null!=l&&y>=d.length-l.length||null==l&&a,n(k,x,t,c,q(d,y+1,e),B,m),(a||p<z)&&h(k,r(x),q(d,u,e)),y--,p++;else break;else y--,p++;else u++,p++}for(;y>=u&&z>=p;){x=d[y];t=b[z];if(x!==t||a)if(null==x)y--;else{if(null!=t)if(x.key===t.key)B=null!=l&&y>=d.length-l.length||null==l&&a,n(k,x,t,c,q(d,y+1,e),B,m),a&&x.tag===t.tag&& | ||
h(k,r(x),e),null!=x.dom&&(e=x.dom),y--;else{if(!J){J=d;x=y;B={};var v;for(v=0;v<x;v++){var w=J[v];null!=w&&(w=w.key,null!=w&&(B[w]=v))}J=B}null!=t&&(x=J[t.key],null!=x?(B=d[x],n(k,B,t,c,q(d,y+1,e),a,m),h(k,r(B),e),d[x].skip=!0,null!=B.dom&&(e=B.dom)):e=f(k,t,c,m,e))}z--}else y--,z--;if(z<p)break}g(k,b,p,z+1,c,e,m);C(d,u,y+1,b)}}function n(k,d,a,c,h,g,q){var p=d.tag;if(p===a.tag){a.state=d.state;a._state=d._state;a.events=d.events;var u;if(u=!g){var y,C;null!=a.attrs&&"function"===typeof a.attrs.onbeforeupdate&& | ||
(y=a.attrs.onbeforeupdate.call(a.state,a,d));"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeupdate&&(C=a._state.onbeforeupdate.call(a.state,a,d));void 0===y&&void 0===C||y||C?u=!1:(a.dom=d.dom,a.domSize=d.domSize,a.instance=d.instance,u=!0)}if(!u)if("string"===typeof p)switch(null!=a.attrs&&(g?(a.state={},K(a.attrs,a,c)):L(a.attrs,a,c)),p){case "#":d.children.toString()!==a.children.toString()&&(d.dom.nodeValue=a.children);a.dom=d.dom;break;case "<":d.children!==a.children?(r(d),e(k, | ||
a,h)):(a.dom=d.dom,a.domSize=d.domSize);break;case "[":l(k,d.children,a.children,g,c,h,q);d=0;c=a.children;a.dom=null;if(null!=c){for(g=0;g<c.length;g++){var t=c[g];null!=t&&null!=t.dom&&(null==a.dom&&(a.dom=t.dom),d+=t.domSize||1)}1!==d&&(a.domSize=d)}break;default:k=a.dom=d.dom;q=a.attrs&&a.attrs.xmlns||H[a.tag]||q;"textarea"===a.tag&&(null==a.attrs&&(a.attrs={}),null!=a.text&&(a.attrs.value=a.text,a.text=void 0));h=d.attrs;p=a.attrs;u=q;if(null!=p)for(t in p)z(a,t,h&&h[t],p[t],u);if(null!=h)for(t in h)null!= | ||
p&&t in p||("className"===t&&(t="class"),"o"!==t[0]||"n"!==t[1]||v(t)?"key"!==t&&a.dom.removeAttribute(t):A(a,t,void 0));null!=a.attrs&&null!=a.attrs.contenteditable?b(a):null!=d.text&&null!=a.text&&""!==a.text?d.text.toString()!==a.text.toString()&&(d.dom.firstChild.nodeValue=a.text):(null!=d.text&&(d.children=[w("#",void 0,void 0,d.text,void 0,d.dom.firstChild)]),null!=a.text&&(a.children=[w("#",void 0,void 0,a.text,void 0,void 0)]),l(k,d.children,a.children,g,c,null,q))}else{if(g)m(a,c);else{a.instance= | ||
w.normalize(a._state.view.call(a.state,a));if(a.instance===a)throw Error("A view cannot return the vnode it received as argument");null!=a.attrs&&L(a.attrs,a,c);L(a._state,a,c)}null!=a.instance?(null==d.instance?f(k,a.instance,c,q,h):n(k,d.instance,a.instance,c,h,g,q),a.dom=a.instance.dom,a.domSize=a.instance.domSize):null!=d.instance?(B(d.instance,null),a.dom=void 0,a.domSize=0):(a.dom=d.dom,a.domSize=d.domSize)}}else B(d,null),f(k,a,c,q,h)}function r(a){var d=a.domSize;if(null!=d||null==a.dom){var b= | ||
D.createDocumentFragment();if(0<d){for(a=a.dom;--d;)b.appendChild(a.nextSibling);b.insertBefore(a,b.firstChild)}return b}return a.dom}function q(a,d,b){for(;d<a.length;d++)if(null!=a[d]&&null!=a[d].dom)return a[d].dom;return b}function h(a,d,b){b&&b.parentNode?a.insertBefore(d,b):a.appendChild(d)}function b(a){var d=a.children;if(null!=d&&1===d.length&&"<"===d[0].tag)d=d[0].children,a.dom.innerHTML!==d&&(a.dom.innerHTML=d);else if(null!=a.text||null!=d&&0!==d.length)throw Error("Child node of a contenteditable must be trusted"); | ||
}function C(a,d,b,c){for(;d<b;d++){var k=a[d];null!=k&&(k.skip?k.skip=!1:B(k,c))}}function B(a,d){function b(){if(++k===c&&(G(a),a.dom)){var b=a.domSize||1;if(1<b)for(var f=a.dom;--b;){var e=f.nextSibling,h=e.parentNode;null!=h&&h.removeChild(e)}b=a.dom;f=b.parentNode;null!=f&&f.removeChild(b);if(b=null!=d&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(d.pool?d.pool.push(a):d.pool=[a])}}var c=1,k=0;if(a.attrs&&"function"=== | ||
typeof a.attrs.onbeforeremove){var f=a.attrs.onbeforeremove.call(a.state,a);null!=f&&"function"===typeof f.then&&(c++,f.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeremove&&(f=a._state.onbeforeremove.call(a.state,a),null!=f&&"function"===typeof f.then&&(c++,f.then(b,b)));b()}function G(a){a.attrs&&"function"===typeof a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag)"function"===typeof a._state.onremove&&a._state.onremove.call(a.state,a),null!= | ||
a.instance&&G(a.instance);else if(a=a.children,Array.isArray(a))for(var b=0;b<a.length;b++){var c=a[b];null!=c&&G(c)}}function z(a,b,f,e,h){var d=a.dom;if("key"!==b&&"is"!==b&&(f!==e||"value"===b||"checked"===b||"selectedIndex"===b||"selected"===b&&a.dom===c()||"object"===typeof e)&&"undefined"!==typeof e&&!v(b)){var k=b.indexOf(":");if(-1<k&&"xlink"===b.substr(0,k))d.setAttributeNS("http://www.w3.org/1999/xlink",b.slice(k+1),e);else if("o"===b[0]&&"n"===b[1]&&"function"===typeof e)A(a,b,e);else if("style"=== | ||
b)if(a=f,a===e&&(d.style.cssText="",a=null),null==e)d.style.cssText="";else if("string"===typeof e)d.style.cssText=e;else{"string"===typeof a&&(d.style.cssText="");for(var g in e)d.style[g]=e[g];if(null!=a&&"string"!==typeof a)for(g in a)g in e||(d.style[g]="")}else if(b in d&&"href"!==b&&"list"!==b&&"form"!==b&&"width"!==b&&"height"!==b&&void 0===h&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===b){g=""+e;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===g&&a.dom===c())return;if("select"=== | ||
a.tag)if(null===e){if(-1===a.dom.selectedIndex&&a.dom===c())return}else if(null!==f&&a.dom.value===g&&a.dom===c())return;if("option"===a.tag&&null!=f&&a.dom.value===g)return}"input"===a.tag&&"type"===b?d.setAttribute(b,e):d[b]=e}else"boolean"===typeof e?e?d.setAttribute(b,""):d.removeAttribute(b):d.setAttribute("className"===b?"class":b,e)}}function v(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function A(a,b,c){var d=a.dom,e="function"!== | ||
typeof F?c:function(a){var b=c.call(d,a);F.call(d,a);return b};if(b in d)d[b]="function"===typeof c?e:null;else{var f=b.slice(2);void 0===a.events&&(a.events={});a.events[b]!==e&&(null!=a.events[b]&&d.removeEventListener(f,a.events[b],!1),"function"===typeof c&&(a.events[b]=e,d.addEventListener(f,a.events[b],!1)))}}function K(a,b,c){"function"===typeof a.oninit&&a.oninit.call(b.state,b);"function"===typeof a.oncreate&&c.push(a.oncreate.bind(b.state,b))}function L(a,b,c){"function"===typeof a.onupdate&& | ||
c.push(a.onupdate.bind(b.state,b))}var D=a.document,E=D.createDocumentFragment(),H={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},F;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=c(),f=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);l(a,a.vnodes,w.normalizeChildren(b),!1,d,null,"http://www.w3.org/1999/xhtml"===f?void 0:f);a.vnodes=b;null!=e&&c()!== | ||
e&&e.focus();for(e=0;e<d.length;e++)d[e]()},setEventCallback:function(a){return F=a}}},F=function(a){function c(a){a=f.indexOf(a);-1<a&&f.splice(a,2)}function g(){for(var a=1;a<f.length;a+=2)f[a]()}a=Q(a);a.setEventCallback(function(a){!1===a.redraw?a.redraw=void 0:g()});var f=[];return{subscribe:function(a,g){c(a);f.push(a,S(g))},unsubscribe:c,redraw:g,render:a.render}}(window);M.setCompletionCallback(F.redraw);A.mount=function(a){return function(c,g){if(null===g)a.render(c,[]),a.unsubscribe(c); | ||
else{if(null==g.view&&"function"!==typeof g)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(c,function(){a.render(c,w(g))});a.redraw()}}}(F);var V=v,N=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var c={},g={},f=0;f<a.length;f++){var e=a[f].split("="),m=decodeURIComponent(e[0]);e=2===e.length?decodeURIComponent(e[1]):"";"true"===e?e=!0:"false"===e&&(e=!1);var l=m.split(/\]\[?|\[/),n=g;-1<m.indexOf("[")&&l.pop(); | ||
for(var r=0;r<l.length;r++){m=l[r];var q=l[r+1];q=""==q||!isNaN(parseInt(q,10));if(""===m)m=l.slice(0,r).join(),null==c[m]&&(c[m]=Array.isArray(n)?n.length:0),m=c[m]++;else if("__proto__"===m)break;if(r===l.length-1)n[m]=e;else{var h=Object.getOwnPropertyDescriptor(n,m);null!=h&&(h=h.value);null==h&&(n[m]=h=q?[]:{});n=h}}}return g},W=function(a){function c(c){var f=a.location[c].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===c&&"/"!==f[0]&&(f="/"+f);return f}function g(a){return function(){null== | ||
l&&(l=m(function(){l=null;a()}))}}function f(a,c,f){var b=a.indexOf("?"),e=a.indexOf("#"),h=-1<b?b:-1<e?e:a.length;if(-1<b){b=N(a.slice(b+1,-1<e?e:a.length));for(var g in b)c[g]=b[g]}if(-1<e)for(g in c=N(a.slice(e+1)),c)f[g]=c[g];return a.slice(0,h)}var e="function"===typeof a.history.pushState,m="function"===typeof setImmediate?setImmediate:setTimeout,l,n={prefix:"#!",getPath:function(){switch(n.prefix.charAt(0)){case "#":return c("hash").slice(n.prefix.length);case "?":return c("search").slice(n.prefix.length)+ | ||
c("hash");default:return c("pathname").slice(n.prefix.length)+c("search")+c("hash")}},setPath:function(c,g,h){var b={},m={};c=f(c,b,m);if(null!=g){for(var l in g)b[l]=g[l];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return g[c]})}(l=H(b))&&(c+="?"+l);(m=H(m))&&(c+="#"+m);e?(m=h?h.state:null,l=h?h.title:null,a.onpopstate(),h&&h.replace?a.history.replaceState(m,l,n.prefix+c):a.history.pushState(m,l,n.prefix+c)):a.location.href=n.prefix+c},defineRoutes:function(c,m,h){function b(){var b=n.getPath(), | ||
e={},g=f(b,e,e),l=a.history.state;if(null!=l)for(var r in l)e[r]=l[r];for(var q in c)if(l=new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),l.test(g)){g.replace(l,function(){for(var a=q.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,1,-2),g=0;g<a.length;g++)e[a[g].replace(/:|\./g,"")]=decodeURIComponent(f[g]);m(c[q],e,b,q)});return}h(b,e)}e?a.onpopstate=g(b):"#"===n.prefix.charAt(0)&&(a.onhashchange=b);b()}};return n};A.route=function(a,c){var g=W(a),f=function(a){return a}, | ||
e,m,l,n,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 h=function(){null!=e&&c.render(a,e(w(m,l.key,l)))},v=function(a){if(a!==b)g.setPath(b,null,{replace:!0});else throw Error("Could not resolve default route "+b);};g.defineRoutes(q,function(a,b,c){var g=r=function(a,q){g===r&&(m=null==q||"function"!==typeof q.view&&"function"!==typeof q?"div":q,l=b,n=c,r=null,e=(a.render||f).bind(a),h())};a.view||"function"===typeof a?g({}, | ||
a):a.onmatch?V.resolve(a.onmatch(b,c)).then(function(b){g(a,b)},v):g(a,"div")},v);c.subscribe(a,h)};q.set=function(a,b,c){null!=r&&(c=c||{},c.replace=!0);r=null;g.setPath(a,b,c)};q.get=function(){return n};q.prefix=function(a){g.prefix=a};q.link=function(a){a.dom.setAttribute("href",g.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(g.prefix)&&(a=a.slice(g.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);A.withAttr=function(a,c,g){return function(f){c.call(g||this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var X=Q(window);A.render=X.render;A.redraw=F.redraw;A.request=M.request;A.jsonp=M.jsonp;A.parseQueryString=N;A.buildQueryString=H;A.version="1.1.7";A.vnode=w;"undefined"!==typeof module?module.exports=A:window.m=A})(); |
{ | ||
"name": "mithril", | ||
"version": "1.1.6", | ||
"version": "1.1.7", | ||
"description": "A framework for building brilliant applications", | ||
@@ -24,3 +24,3 @@ "author": "Leo Horie", | ||
"preversion": "npm run test", | ||
"version": "npm run build && git add mithril.js mithril.min.js", | ||
"version": "npm run build && git add index.js mithril.js mithril.min.js README.md", | ||
"postversion": "git push --follow-tags" | ||
@@ -27,0 +27,0 @@ }, |
@@ -7,3 +7,3 @@ "use strict" | ||
var entries = string.split("&"), data = {}, counters = {} | ||
var entries = string.split("&"), counters = {}, data = {} | ||
for (var i = 0; i < entries.length; i++) { | ||
@@ -23,12 +23,20 @@ var entry = entries[i].split("=") | ||
var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10)) | ||
var isValue = j === levels.length - 1 | ||
if (level === "") { | ||
var key = levels.slice(0, j).join() | ||
if (counters[key] == null) counters[key] = 0 | ||
if (counters[key] == null) { | ||
counters[key] = Array.isArray(cursor) ? cursor.length : 0 | ||
} | ||
level = counters[key]++ | ||
} | ||
if (cursor[level] == null) { | ||
cursor[level] = isValue ? value : isNumber ? [] : {} | ||
// Disallow direct prototype pollution | ||
else if (level === "__proto__") break | ||
if (j === levels.length - 1) cursor[level] = value | ||
else { | ||
// Read own properties exclusively to disallow indirect | ||
// prototype pollution | ||
var desc = Object.getOwnPropertyDescriptor(cursor, level) | ||
if (desc != null) desc = desc.value | ||
if (desc == null) cursor[level] = desc = isNumber ? [] : {} | ||
cursor = desc | ||
} | ||
cursor = cursor[level] | ||
} | ||
@@ -35,0 +43,0 @@ } |
@@ -96,2 +96,21 @@ "use strict" | ||
}) | ||
o("prefers later values", function() { | ||
var data = parseQueryString("a=1&b=2&a=3") | ||
o(data).deepEquals({a: "3", b: "2"}) | ||
}) | ||
o("doesn't pollute prototype directly, censors `__proto__`", function() { | ||
var prev = Object.prototype.toString | ||
var data = parseQueryString("a=b&__proto__%5BtoString%5D=123") | ||
o(Object.prototype.toString).equals(prev) | ||
o(data).deepEquals({a: "b"}) | ||
}) | ||
o("doesn't pollute prototype indirectly, retains `constructor`", function() { | ||
var prev = Object.prototype.toString | ||
var data = parseQueryString("a=b&constructor%5Bprototype%5D%5BtoString%5D=123") | ||
o(Object.prototype.toString).equals(prev) | ||
// The deep matcher is borked here. | ||
o(Object.keys(data)).deepEquals(["a", "constructor"]) | ||
o(data.a).equals("b") | ||
o(data.constructor).deepEquals({prototype: {toString: "123"}}) | ||
}) | ||
}) |
@@ -21,2 +21,11 @@ "use strict" | ||
// IE9 - IE11 (at least) throw an UnspecifiedError when accessing document.activeElement when | ||
// inside an iframe. Catch and swallow this error, and heavy-handidly return null. | ||
function activeElement() { | ||
try { | ||
return $doc.activeElement | ||
} catch (e) { | ||
return null | ||
} | ||
} | ||
//create | ||
@@ -488,9 +497,9 @@ function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) { | ||
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome | ||
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return | ||
if ((vnode.tag === "input" || vnode.tag === "textarea") && vnode.dom.value === normalized && vnode.dom === activeElement()) return | ||
//setting select[value] to same value while having select open blinks select dropdown in Chrome | ||
if (vnode.tag === "select") { | ||
if (value === null) { | ||
if (vnode.dom.selectedIndex === -1 && vnode.dom === $doc.activeElement) return | ||
if (vnode.dom.selectedIndex === -1 && vnode.dom === activeElement()) return | ||
} else { | ||
if (old !== null && vnode.dom.value === normalized && vnode.dom === $doc.activeElement) return | ||
if (old !== null && vnode.dom.value === normalized && vnode.dom === activeElement()) return | ||
} | ||
@@ -540,3 +549,3 @@ } | ||
function isFormAttribute(vnode, attr) { | ||
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === $doc.activeElement | ||
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === activeElement() | ||
} | ||
@@ -619,3 +628,3 @@ function isLifecycleMethod(attr) { | ||
var hooks = [] | ||
var active = $doc.activeElement | ||
var active = activeElement() | ||
var namespace = dom.namespaceURI | ||
@@ -630,3 +639,3 @@ | ||
// document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement | ||
if (active != null && $doc.activeElement !== active) active.focus() | ||
if (active != null && activeElement() !== active) active.focus() | ||
for (var i = 0; i < hooks.length; i++) hooks[i]() | ||
@@ -633,0 +642,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1178720
197
17639