Bundled output for commit 966e78bcab [skip ci]

This commit is contained in:
Gandalf-the-Bot 2018-12-06 05:21:03 +00:00
parent 966e78bcab
commit bd25a8b37d
4 changed files with 634 additions and 556 deletions

View file

@ -1,7 +1,7 @@
;(function() { ;(function() {
"use strict" "use strict"
function Vnode(tag, key, attrs0, children, text, dom) { function Vnode(tag, key, attrs0, children0, text, dom) {
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined} return {tag: tag, key: key, attrs: attrs0, children: children0, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}
} }
Vnode.normalize = function(node) { Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined) if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
@ -9,11 +9,57 @@ Vnode.normalize = function(node) {
return node return node
} }
Vnode.normalizeChildren = function(input) { Vnode.normalizeChildren = function(input) {
var children = [] var children0 = []
for (var i = 0; i < input.length; i++) { for (var i = 0; i < input.length; i++) {
children[i] = Vnode.normalize(input[i]) children0[i] = Vnode.normalize(input[i])
} }
return children return children0
}
// Call via `hyperscriptVnode0.apply(startOffset, arguments)`
//
// The reason I do it this way, forwarding the arguments and passing the start
// offset in `this`, is so I don't have to create a temporary array in a
// performance-critical path.
//
// In native ES6, I'd instead add a final `...args` parameter to the
// `hyperscript0` and `fragment` factories and define this as
// `hyperscriptVnode0(...args)`, since modern engines do optimize that away. But
// ES5 (what Mithril requires thanks to IE support) doesn't give me that luxury,
// and engines aren't nearly intelligent enough to do either of these:
//
// 1. Elide the allocation for `[].slice.call(arguments, 1)` when it's passed to
// another function only to be indexed.
// 2. Elide an `arguments` allocation when it's passed to any function other
// than `Function.prototype.apply` or `Reflect.apply`.
//
// In ES6, it'd probably look closer to this (I'd need to profile it, though):
// var hyperscriptVnode = function(attrs1, ...children1) {
// if (attrs1 == null || typeof attrs1 === "object" && attrs1.tag == null && !Array.isArray(attrs1)) {
// if (children1.length === 1 && Array.isArray(children1[0])) children1 = children1[0]
// } else {
// children1 = children1.length === 0 && Array.isArray(attrs1) ? attrs1 : [attrs1, ...children1]
// attrs1 = undefined
// }
//
// if (attrs1 == null) attrs1 = {}
// return Vnode("", attrs1.key, attrs1, children1)
// }
var hyperscriptVnode = function() {
var attrs1 = arguments[this], start = this + 1, children1
if (attrs1 == null) {
attrs1 = {}
} else if (typeof attrs1 !== "object" || attrs1.tag != null || Array.isArray(attrs1)) {
attrs1 = {}
start = this
}
if (arguments.length === start + 1) {
children1 = arguments[start]
if (!Array.isArray(children1)) children1 = [children1]
} else {
children1 = []
while (start < arguments.length) children1.push(arguments[start++])
}
return Vnode("", attrs1.key, attrs1, children1)
} }
var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
var selectorCache = {} var selectorCache = {}
@ -39,16 +85,18 @@ function compileSelector(selector) {
if (classes.length > 0) attrs.className = classes.join(" ") if (classes.length > 0) attrs.className = classes.join(" ")
return selectorCache[selector] = {tag: tag, attrs: attrs} return selectorCache[selector] = {tag: tag, attrs: attrs}
} }
function execSelector(state, attrs, children) { function execSelector(state, vnode) {
var hasAttrs = false, childList, text var attrs = vnode.attrs
var classAttr = hasOwn.call(attrs, "class") ? "class" : "className" var children = Vnode.normalizeChildren(vnode.children)
var className = attrs[classAttr] var hasClass = hasOwn.call(attrs, "class")
var className = hasClass ? attrs.class : attrs.className
vnode.tag = state.tag
vnode.attrs = null
vnode.children = undefined
if (!isEmpty(state.attrs) && !isEmpty(attrs)) { if (!isEmpty(state.attrs) && !isEmpty(attrs)) {
var newAttrs = {} var newAttrs = {}
for(var key in attrs) { for (var key in attrs) {
if (hasOwn.call(attrs, key)) { if (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key]
newAttrs[key] = attrs[key]
}
} }
attrs = newAttrs attrs = newAttrs
} }
@ -65,50 +113,41 @@ function execSelector(state, attrs, children) {
: state.attrs.className != null : state.attrs.className != null
? state.attrs.className ? state.attrs.className
: null : null
if (classAttr === "class") attrs.class = null if (hasClass) attrs.class = null
for (var key in attrs) { for (var key in attrs) {
if (hasOwn.call(attrs, key) && key !== "key") { if (hasOwn.call(attrs, key) && key !== "key") {
hasAttrs = true vnode.attrs = attrs
break break
} }
} }
if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") { if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") {
text = children[0].children vnode.text = children[0].children
} else { } else {
childList = children vnode.children = children
} }
return Vnode(state.tag, attrs.key, hasAttrs ? attrs : null, childList, text) return vnode
} }
function hyperscript(selector) { function hyperscript(selector) {
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") { if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component."); throw Error("The selector must be either a string or a component.");
} }
var attrs = arguments[1], start = 2, children var vnode = hyperscriptVnode.apply(1, arguments)
if (attrs == null) {
attrs = {}
} else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) {
attrs = {}
start = 1
}
if (arguments.length === start + 1) {
children = arguments[start]
if (!Array.isArray(children)) children = [children]
} else {
children = []
while (start < arguments.length) children.push(arguments[start++])
}
if (typeof selector === "string") { if (typeof selector === "string") {
return execSelector(selectorCache[selector] || compileSelector(selector), attrs, Vnode.normalizeChildren(children)) return execSelector(selectorCache[selector] || compileSelector(selector), vnode)
} else { } else {
return Vnode(selector, attrs.key, attrs, children) vnode.tag = selector
return vnode
} }
} }
hyperscript.trust = function(html) { hyperscript.trust = function(html) {
if (html == null) html = "" if (html == null) html = ""
return Vnode("<", undefined, undefined, html, undefined, undefined) return Vnode("<", undefined, undefined, html, undefined, undefined)
} }
hyperscript.fragment = function(attrs1, children0) { hyperscript.fragment = function() {
return Vnode("[", attrs1.key, attrs1, Vnode.normalizeChildren(children0), undefined, undefined) var vnode2 = hyperscriptVnode.apply(0, arguments)
vnode2.tag = "["
vnode2.children = Vnode.normalizeChildren(vnode2.children)
return vnode2
} }
var m = function m() { return hyperscript.apply(this, arguments) } var m = function m() { return hyperscript.apply(this, arguments) }
m.m = hyperscript m.m = hyperscript
@ -258,7 +297,7 @@ var buildQueryString = function(object) {
else args.push(encodeURIComponent(key) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : "")) else args.push(encodeURIComponent(key) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : ""))
} }
} }
var _9 = function($window, Promise) { var _12 = function($window, Promise) {
var callbackCount = 0 var callbackCount = 0
var oncompletion var oncompletion
function makeRequest(factory) { function makeRequest(factory) {
@ -406,7 +445,7 @@ var _9 = function($window, Promise) {
}, },
} }
} }
var requestService = _9(window, PromisePolyfill) var requestService = _12(window, PromisePolyfill)
var coreRenderer = function($window) { var coreRenderer = function($window) {
var $doc = $window.document var $doc = $window.document
var nameSpace = { var nameSpace = {
@ -415,23 +454,23 @@ var coreRenderer = function($window) {
} }
var redraw0 var redraw0
function setRedraw(callback) {return redraw0 = callback} function setRedraw(callback) {return redraw0 = callback}
function getNameSpace(vnode) { function getNameSpace(vnode3) {
return vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag] return vnode3.attrs && vnode3.attrs.xmlns || nameSpace[vnode3.tag]
} }
//sanity check to discourage people from doing `vnode.state = ...` //sanity check to discourage people from doing `vnode3.state = ...`
function checkState(vnode, original) { function checkState(vnode3, original) {
if (vnode.state !== original) throw new Error("`vnode.state` must not be modified") if (vnode3.state !== original) throw new Error("`vnode.state` must not be modified")
} }
//Note: the hook is passed as the `this` argument to allow proxying the //Note: the hook is passed as the `this` argument to allow proxying the
//arguments without requiring a full array allocation to do so. It also //arguments without requiring a full array allocation to do so. It also
//takes advantage of the fact the current `vnode` is the first argument in //takes advantage of the fact the current `vnode3` is the first argument in
//all lifecycle methods. //all lifecycle methods.
function callHook(vnode) { function callHook(vnode3) {
var original = vnode.state var original = vnode3.state
try { try {
return this.apply(original, arguments) return this.apply(original, arguments)
} finally { } finally {
checkState(vnode, original) checkState(vnode3, original)
} }
} }
// IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when // IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when
@ -446,33 +485,33 @@ var coreRenderer = function($window) {
//create //create
function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) { function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
for (var i = start; i < end; i++) { for (var i = start; i < end; i++) {
var vnode = vnodes[i] var vnode3 = vnodes[i]
if (vnode != null) { if (vnode3 != null) {
createNode(parent, vnode, hooks, ns, nextSibling) createNode(parent, vnode3, hooks, ns, nextSibling)
} }
} }
} }
function createNode(parent, vnode, hooks, ns, nextSibling) { function createNode(parent, vnode3, hooks, ns, nextSibling) {
var tag = vnode.tag var tag = vnode3.tag
if (typeof tag === "string") { if (typeof tag === "string") {
vnode.state = {} vnode3.state = {}
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) initLifecycle(vnode3.attrs, vnode3, hooks)
switch (tag) { switch (tag) {
case "#": createText(parent, vnode, nextSibling); break case "#": createText(parent, vnode3, nextSibling); break
case "<": createHTML(parent, vnode, ns, nextSibling); break case "<": createHTML(parent, vnode3, ns, nextSibling); break
case "[": createFragment(parent, vnode, hooks, ns, nextSibling); break case "[": createFragment(parent, vnode3, hooks, ns, nextSibling); break
default: createElement(parent, vnode, hooks, ns, nextSibling) default: createElement(parent, vnode3, hooks, ns, nextSibling)
} }
} }
else createComponent(parent, vnode, hooks, ns, nextSibling) else createComponent(parent, vnode3, hooks, ns, nextSibling)
} }
function createText(parent, vnode, nextSibling) { function createText(parent, vnode3, nextSibling) {
vnode.dom = $doc.createTextNode(vnode.children) vnode3.dom = $doc.createTextNode(vnode3.children)
insertNode(parent, vnode.dom, nextSibling) insertNode(parent, vnode3.dom, nextSibling)
} }
var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"} var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}
function createHTML(parent, vnode, ns, nextSibling) { function createHTML(parent, vnode3, ns, nextSibling) {
var match0 = vnode.children.match(/^\s*?<(\w+)/im) || [] var match0 = vnode3.children.match(/^\s*?<(\w+)/im) || []
// not using the proper parent makes the child element(s) vanish. // not using the proper parent makes the child element(s) vanish.
// var div = document.createElement("div") // var div = document.createElement("div")
// div.innerHTML = "<td>i</td><td>j</td>" // div.innerHTML = "<td>i</td><td>j</td>"
@ -480,13 +519,13 @@ var coreRenderer = function($window) {
// --> "ij", no <td> in sight. // --> "ij", no <td> in sight.
var temp = $doc.createElement(possibleParents[match0[1]] || "div") var temp = $doc.createElement(possibleParents[match0[1]] || "div")
if (ns === "http://www.w3.org/2000/svg") { if (ns === "http://www.w3.org/2000/svg") {
temp.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + vnode.children + "</svg>" temp.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + vnode3.children + "</svg>"
temp = temp.firstChild temp = temp.firstChild
} else { } else {
temp.innerHTML = vnode.children temp.innerHTML = vnode3.children
} }
vnode.dom = temp.firstChild vnode3.dom = temp.firstChild
vnode.domSize = temp.childNodes.length vnode3.domSize = temp.childNodes.length
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
var child var child
while (child = temp.firstChild) { while (child = temp.firstChild) {
@ -494,73 +533,73 @@ var coreRenderer = function($window) {
} }
insertNode(parent, fragment, nextSibling) insertNode(parent, fragment, nextSibling)
} }
function createFragment(parent, vnode, hooks, ns, nextSibling) { function createFragment(parent, vnode3, hooks, ns, nextSibling) {
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
if (vnode.children != null) { if (vnode3.children != null) {
var children1 = vnode.children var children3 = vnode3.children
createNodes(fragment, children1, 0, children1.length, hooks, null, ns) createNodes(fragment, children3, 0, children3.length, hooks, null, ns)
} }
vnode.dom = fragment.firstChild vnode3.dom = fragment.firstChild
vnode.domSize = fragment.childNodes.length vnode3.domSize = fragment.childNodes.length
insertNode(parent, fragment, nextSibling) insertNode(parent, fragment, nextSibling)
} }
function createElement(parent, vnode, hooks, ns, nextSibling) { function createElement(parent, vnode3, hooks, ns, nextSibling) {
var tag = vnode.tag var tag = vnode3.tag
var attrs2 = vnode.attrs var attrs2 = vnode3.attrs
var is = attrs2 && attrs2.is var is = attrs2 && attrs2.is
ns = getNameSpace(vnode) || ns ns = getNameSpace(vnode3) || ns
var element = ns ? var element = ns ?
is ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) : is ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :
is ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag) is ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)
vnode.dom = element vnode3.dom = element
if (attrs2 != null) { if (attrs2 != null) {
setAttrs(vnode, attrs2, ns) setAttrs(vnode3, attrs2, ns)
} }
insertNode(parent, element, nextSibling) insertNode(parent, element, nextSibling)
if (attrs2 != null && attrs2.contenteditable != null) { if (attrs2 != null && attrs2.contenteditable != null) {
setContentEditable(vnode) setContentEditable(vnode3)
} }
else { else {
if (vnode.text != null) { if (vnode3.text != null) {
if (vnode.text !== "") element.textContent = vnode.text if (vnode3.text !== "") element.textContent = vnode3.text
else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] else vnode3.children = [Vnode("#", undefined, undefined, vnode3.text, undefined, undefined)]
} }
if (vnode.children != null) { if (vnode3.children != null) {
var children1 = vnode.children var children3 = vnode3.children
createNodes(element, children1, 0, children1.length, hooks, null, ns) createNodes(element, children3, 0, children3.length, hooks, null, ns)
if (vnode.tag === "select" && attrs2 != null) setLateSelectAttrs(vnode, attrs2) if (vnode3.tag === "select" && attrs2 != null) setLateSelectAttrs(vnode3, attrs2)
} }
} }
} }
function initComponent(vnode, hooks) { function initComponent(vnode3, hooks) {
var sentinel var sentinel
if (typeof vnode.tag.view === "function") { if (typeof vnode3.tag.view === "function") {
vnode.state = Object.create(vnode.tag) vnode3.state = Object.create(vnode3.tag)
sentinel = vnode.state.view sentinel = vnode3.state.view
if (sentinel.$$reentrantLock$$ != null) return if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true sentinel.$$reentrantLock$$ = true
} else { } else {
vnode.state = void 0 vnode3.state = void 0
sentinel = vnode.tag sentinel = vnode3.tag
if (sentinel.$$reentrantLock$$ != null) return if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true sentinel.$$reentrantLock$$ = true
vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode) vnode3.state = (vnode3.tag.prototype != null && typeof vnode3.tag.prototype.view === "function") ? new vnode3.tag(vnode3) : vnode3.tag(vnode3)
} }
initLifecycle(vnode.state, vnode, hooks) initLifecycle(vnode3.state, vnode3, hooks)
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) initLifecycle(vnode3.attrs, vnode3, hooks)
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode)) vnode3.instance = Vnode.normalize(callHook.call(vnode3.state.view, vnode3))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument") if (vnode3.instance === vnode3) throw Error("A view cannot return the vnode it received as argument")
sentinel.$$reentrantLock$$ = null sentinel.$$reentrantLock$$ = null
} }
function createComponent(parent, vnode, hooks, ns, nextSibling) { function createComponent(parent, vnode3, hooks, ns, nextSibling) {
initComponent(vnode, hooks) initComponent(vnode3, hooks)
if (vnode.instance != null) { if (vnode3.instance != null) {
createNode(parent, vnode.instance, hooks, ns, nextSibling) createNode(parent, vnode3.instance, hooks, ns, nextSibling)
vnode.dom = vnode.instance.dom vnode3.dom = vnode3.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0 vnode3.domSize = vnode3.dom != null ? vnode3.instance.domSize : 0
} }
else { else {
vnode.domSize = 0 vnode3.domSize = 0
} }
} }
//update //update
@ -610,7 +649,7 @@ var coreRenderer = function($window) {
// 4) figure out what nodes in 1) to move in order to minimize the DOM operations. // 4) figure out what nodes in 1) to move in order to minimize the DOM operations.
// //
// To achieve 1) one can create a dictionary of keys => index0 (for the old list), then1 iterate // To achieve 1) one can create a dictionary of keys => index0 (for the old list), then1 iterate
// over the new list and for each new vnode, find the corresponding vnode in the old list using // over the new list and for each new vnode3, find the corresponding vnode3 in the old list using
// the map. // the map.
// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new // 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new
// and must be created. // and must be created.
@ -644,7 +683,7 @@ var coreRenderer = function($window) {
// //
// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations. // `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.
// When the list is being traversed top-down, at any index0, the DOM nodes up to the previous // When the list is being traversed top-down, at any index0, the DOM nodes up to the previous
// vnode reflect the content of the new list, whereas the rest of the DOM nodes reflect the old // vnode3 reflect the content of the new list, whereas the rest of the DOM nodes reflect the old
// list. The next0 sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`. // list. The next0 sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`.
// //
// In the other scenarios (swaps, upwards traversal, map-based diff), // In the other scenarios (swaps, upwards traversal, map-based diff),
@ -819,108 +858,108 @@ var coreRenderer = function($window) {
} }
} }
} }
function updateNode(parent, old, vnode, hooks, nextSibling, ns) { function updateNode(parent, old, vnode3, hooks, nextSibling, ns) {
var oldTag = old.tag, tag = vnode.tag var oldTag = old.tag, tag = vnode3.tag
if (oldTag === tag) { if (oldTag === tag) {
vnode.state = old.state vnode3.state = old.state
vnode.events = old.events vnode3.events = old.events
if (shouldNotUpdate(vnode, old)) return if (shouldNotUpdate(vnode3, old)) return
if (typeof oldTag === "string") { if (typeof oldTag === "string") {
if (vnode.attrs != null) { if (vnode3.attrs != null) {
updateLifecycle(vnode.attrs, vnode, hooks) updateLifecycle(vnode3.attrs, vnode3, hooks)
} }
switch (oldTag) { switch (oldTag) {
case "#": updateText(old, vnode); break case "#": updateText(old, vnode3); break
case "<": updateHTML(parent, old, vnode, ns, nextSibling); break case "<": updateHTML(parent, old, vnode3, ns, nextSibling); break
case "[": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break case "[": updateFragment(parent, old, vnode3, hooks, nextSibling, ns); break
default: updateElement(old, vnode, hooks, ns) default: updateElement(old, vnode3, hooks, ns)
} }
} }
else updateComponent(parent, old, vnode, hooks, nextSibling, ns) else updateComponent(parent, old, vnode3, hooks, nextSibling, ns)
} }
else { else {
removeNode(old) removeNode(old)
createNode(parent, vnode, hooks, ns, nextSibling) createNode(parent, vnode3, hooks, ns, nextSibling)
} }
} }
function updateText(old, vnode) { function updateText(old, vnode3) {
if (old.children.toString() !== vnode.children.toString()) { if (old.children.toString() !== vnode3.children.toString()) {
old.dom.nodeValue = vnode.children old.dom.nodeValue = vnode3.children
} }
vnode.dom = old.dom vnode3.dom = old.dom
} }
function updateHTML(parent, old, vnode, ns, nextSibling) { function updateHTML(parent, old, vnode3, ns, nextSibling) {
if (old.children !== vnode.children) { if (old.children !== vnode3.children) {
toFragment(old) toFragment(old)
createHTML(parent, vnode, ns, nextSibling) createHTML(parent, vnode3, ns, nextSibling)
} }
else vnode.dom = old.dom, vnode.domSize = old.domSize else vnode3.dom = old.dom, vnode3.domSize = old.domSize
} }
function updateFragment(parent, old, vnode, hooks, nextSibling, ns) { function updateFragment(parent, old, vnode3, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns) updateNodes(parent, old.children, vnode3.children, hooks, nextSibling, ns)
var domSize = 0, children1 = vnode.children var domSize = 0, children3 = vnode3.children
vnode.dom = null vnode3.dom = null
if (children1 != null) { if (children3 != null) {
for (var i = 0; i < children1.length; i++) { for (var i = 0; i < children3.length; i++) {
var child = children1[i] var child = children3[i]
if (child != null && child.dom != null) { if (child != null && child.dom != null) {
if (vnode.dom == null) vnode.dom = child.dom if (vnode3.dom == null) vnode3.dom = child.dom
domSize += child.domSize || 1 domSize += child.domSize || 1
} }
} }
if (domSize !== 1) vnode.domSize = domSize if (domSize !== 1) vnode3.domSize = domSize
} }
} }
function updateElement(old, vnode, hooks, ns) { function updateElement(old, vnode3, hooks, ns) {
var element = vnode.dom = old.dom var element = vnode3.dom = old.dom
ns = getNameSpace(vnode) || ns ns = getNameSpace(vnode3) || ns
if (vnode.tag === "textarea") { if (vnode3.tag === "textarea") {
if (vnode.attrs == null) vnode.attrs = {} if (vnode3.attrs == null) vnode3.attrs = {}
if (vnode.text != null) { if (vnode3.text != null) {
vnode.attrs.value = vnode.text //FIXME handle0 multiple children1 vnode3.attrs.value = vnode3.text //FIXME handle0 multiple children3
vnode.text = undefined vnode3.text = undefined
} }
} }
updateAttrs(vnode, old.attrs, vnode.attrs, ns) updateAttrs(vnode3, old.attrs, vnode3.attrs, ns)
if (vnode.attrs != null && vnode.attrs.contenteditable != null) { if (vnode3.attrs != null && vnode3.attrs.contenteditable != null) {
setContentEditable(vnode) setContentEditable(vnode3)
} }
else if (old.text != null && vnode.text != null && vnode.text !== "") { else if (old.text != null && vnode3.text != null && vnode3.text !== "") {
if (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text if (old.text.toString() !== vnode3.text.toString()) old.dom.firstChild.nodeValue = vnode3.text
} }
else { else {
if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)] if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)]
if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] if (vnode3.text != null) vnode3.children = [Vnode("#", undefined, undefined, vnode3.text, undefined, undefined)]
updateNodes(element, old.children, vnode.children, hooks, null, ns) updateNodes(element, old.children, vnode3.children, hooks, null, ns)
} }
} }
function updateComponent(parent, old, vnode, hooks, nextSibling, ns) { function updateComponent(parent, old, vnode3, hooks, nextSibling, ns) {
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode)) vnode3.instance = Vnode.normalize(callHook.call(vnode3.state.view, vnode3))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument") if (vnode3.instance === vnode3) throw Error("A view cannot return the vnode it received as argument")
updateLifecycle(vnode.state, vnode, hooks) updateLifecycle(vnode3.state, vnode3, hooks)
if (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) updateLifecycle(vnode3.attrs, vnode3, hooks)
if (vnode.instance != null) { if (vnode3.instance != null) {
if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling) if (old.instance == null) createNode(parent, vnode3.instance, hooks, ns, nextSibling)
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, ns) else updateNode(parent, old.instance, vnode3.instance, hooks, nextSibling, ns)
vnode.dom = vnode.instance.dom vnode3.dom = vnode3.instance.dom
vnode.domSize = vnode.instance.domSize vnode3.domSize = vnode3.instance.domSize
} }
else if (old.instance != null) { else if (old.instance != null) {
removeNode(old.instance) removeNode(old.instance)
vnode.dom = undefined vnode3.dom = undefined
vnode.domSize = 0 vnode3.domSize = 0
} }
else { else {
vnode.dom = old.dom vnode3.dom = old.dom
vnode.domSize = old.domSize vnode3.domSize = old.domSize
} }
} }
function getKeyMap(vnodes, start, end) { function getKeyMap(vnodes, start, end) {
var map = Object.create(null) var map = Object.create(null)
for (; start < end; start++) { for (; start < end; start++) {
var vnode = vnodes[start] var vnode3 = vnodes[start]
if (vnode != null) { if (vnode3 != null) {
var key = vnode.key var key = vnode3.key
if (key != null) map[key] = start if (key != null) map[key] = start
} }
} }
@ -973,18 +1012,18 @@ var coreRenderer = function($window) {
} }
return result return result
} }
function toFragment(vnode) { function toFragment(vnode3) {
var count0 = vnode.domSize var count0 = vnode3.domSize
if (count0 != null || vnode.dom == null) { if (count0 != null || vnode3.dom == null) {
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
if (count0 > 0) { if (count0 > 0) {
var dom = vnode.dom var dom = vnode3.dom
while (--count0) fragment.appendChild(dom.nextSibling) while (--count0) fragment.appendChild(dom.nextSibling)
fragment.insertBefore(dom, fragment.firstChild) fragment.insertBefore(dom, fragment.firstChild)
} }
return fragment return fragment
} }
else return vnode.dom else return vnode3.dom
} }
function getNextSibling(vnodes, i, nextSibling) { function getNextSibling(vnodes, i, nextSibling) {
for (; i < vnodes.length; i++) { for (; i < vnodes.length; i++) {
@ -996,33 +1035,33 @@ var coreRenderer = function($window) {
if (nextSibling != null) parent.insertBefore(dom, nextSibling) if (nextSibling != null) parent.insertBefore(dom, nextSibling)
else parent.appendChild(dom) else parent.appendChild(dom)
} }
function setContentEditable(vnode) { function setContentEditable(vnode3) {
var children1 = vnode.children var children3 = vnode3.children
if (children1 != null && children1.length === 1 && children1[0].tag === "<") { if (children3 != null && children3.length === 1 && children3[0].tag === "<") {
var content = children1[0].children var content = children3[0].children
if (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content if (vnode3.dom.innerHTML !== content) vnode3.dom.innerHTML = content
} }
else if (vnode.text != null || children1 != null && children1.length !== 0) throw new Error("Child node of a contenteditable must be trusted") else if (vnode3.text != null || children3 != null && children3.length !== 0) throw new Error("Child node of a contenteditable must be trusted")
} }
//remove //remove
function removeNodes(vnodes, start, end) { function removeNodes(vnodes, start, end) {
for (var i = start; i < end; i++) { for (var i = start; i < end; i++) {
var vnode = vnodes[i] var vnode3 = vnodes[i]
if (vnode != null) removeNode(vnode) if (vnode3 != null) removeNode(vnode3)
} }
} }
function removeNode(vnode) { function removeNode(vnode3) {
var expected = 1, called = 0 var expected = 1, called = 0
var original = vnode.state var original = vnode3.state
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeremove === "function") { if (typeof vnode3.tag !== "string" && typeof vnode3.state.onbeforeremove === "function") {
var result = callHook.call(vnode.state.onbeforeremove, vnode) var result = callHook.call(vnode3.state.onbeforeremove, vnode3)
if (result != null && typeof result.then === "function") { if (result != null && typeof result.then === "function") {
expected++ expected++
result.then(continuation, continuation) result.then(continuation, continuation)
} }
} }
if (vnode.attrs && typeof vnode.attrs.onbeforeremove === "function") { if (vnode3.attrs && typeof vnode3.attrs.onbeforeremove === "function") {
var result = callHook.call(vnode.attrs.onbeforeremove, vnode) var result = callHook.call(vnode3.attrs.onbeforeremove, vnode3)
if (result != null && typeof result.then === "function") { if (result != null && typeof result.then === "function") {
expected++ expected++
result.then(continuation, continuation) result.then(continuation, continuation)
@ -1031,129 +1070,129 @@ var coreRenderer = function($window) {
continuation() continuation()
function continuation() { function continuation() {
if (++called === expected) { if (++called === expected) {
checkState(vnode, original) checkState(vnode3, original)
onremove(vnode) onremove(vnode3)
if (vnode.dom) { if (vnode3.dom) {
var parent = vnode.dom.parentNode var parent = vnode3.dom.parentNode
var count0 = vnode.domSize || 1 var count0 = vnode3.domSize || 1
while (--count0) parent.removeChild(vnode.dom.nextSibling) while (--count0) parent.removeChild(vnode3.dom.nextSibling)
parent.removeChild(vnode.dom) parent.removeChild(vnode3.dom)
} }
} }
} }
} }
function onremove(vnode) { function onremove(vnode3) {
if (typeof vnode.tag !== "string" && typeof vnode.state.onremove === "function") callHook.call(vnode.state.onremove, vnode) if (typeof vnode3.tag !== "string" && typeof vnode3.state.onremove === "function") callHook.call(vnode3.state.onremove, vnode3)
if (vnode.attrs && typeof vnode.attrs.onremove === "function") callHook.call(vnode.attrs.onremove, vnode) if (vnode3.attrs && typeof vnode3.attrs.onremove === "function") callHook.call(vnode3.attrs.onremove, vnode3)
if (typeof vnode.tag !== "string") { if (typeof vnode3.tag !== "string") {
if (vnode.instance != null) onremove(vnode.instance) if (vnode3.instance != null) onremove(vnode3.instance)
} else { } else {
var children1 = vnode.children var children3 = vnode3.children
if (Array.isArray(children1)) { if (Array.isArray(children3)) {
for (var i = 0; i < children1.length; i++) { for (var i = 0; i < children3.length; i++) {
var child = children1[i] var child = children3[i]
if (child != null) onremove(child) if (child != null) onremove(child)
} }
} }
} }
} }
//attrs2 //attrs2
function setAttrs(vnode, attrs2, ns) { function setAttrs(vnode3, attrs2, ns) {
for (var key in attrs2) { for (var key in attrs2) {
setAttr(vnode, key, null, attrs2[key], ns) setAttr(vnode3, key, null, attrs2[key], ns)
} }
} }
function setAttr(vnode, key, old, value, ns) { function setAttr(vnode3, key, old, value, ns) {
if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== "object") return if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode3, key)) && typeof value !== "object") return
if (key[0] === "o" && key[1] === "n") return updateEvent(vnode, key, value) if (key[0] === "o" && key[1] === "n") return updateEvent(vnode3, key, value)
if (key.slice(0, 6) === "xlink:") vnode.dom.setAttributeNS("http://www.w3.org/1999/xlink", key.slice(6), value) if (key.slice(0, 6) === "xlink:") vnode3.dom.setAttributeNS("http://www.w3.org/1999/xlink", key.slice(6), value)
else if (key === "style") updateStyle(vnode.dom, old, value) else if (key === "style") updateStyle(vnode3.dom, old, value)
else if (hasPropertyKey(vnode, key, ns)) { else if (hasPropertyKey(vnode3, key, ns)) {
if (key === "value") { if (key === "value") {
// Only do the coercion if we're actually going to check the value. // Only do the coercion if we're actually going to check the value.
/* eslint-disable no-implicit-coercion */ /* eslint-disable no-implicit-coercion */
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome //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 === "" + value && vnode.dom === activeElement()) return if ((vnode3.tag === "input" || vnode3.tag === "textarea") && vnode3.dom.value === "" + value && vnode3.dom === activeElement()) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome //setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select" && old !== null && vnode.dom.value === "" + value) return if (vnode3.tag === "select" && old !== null && vnode3.dom.value === "" + value) return
//setting option[value] to same value while having select open blinks select dropdown in Chrome //setting option[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return if (vnode3.tag === "option" && old !== null && vnode3.dom.value === "" + value) return
/* eslint-enable no-implicit-coercion */ /* eslint-enable no-implicit-coercion */
} }
// If you assign an input type1 that is not supported by IE 11 with an assignment expression, an error1 will occur. // If you assign an input type1 that is not supported by IE 11 with an assignment expression, an error1 will occur.
if (vnode.tag === "input" && key === "type") vnode.dom.setAttribute(key, value) if (vnode3.tag === "input" && key === "type") vnode3.dom.setAttribute(key, value)
else vnode.dom[key] = value else vnode3.dom[key] = value
} else { } else {
if (typeof value === "boolean") { if (typeof value === "boolean") {
if (value) vnode.dom.setAttribute(key, "") if (value) vnode3.dom.setAttribute(key, "")
else vnode.dom.removeAttribute(key) else vnode3.dom.removeAttribute(key)
} }
else vnode.dom.setAttribute(key === "className" ? "class" : key, value) else vnode3.dom.setAttribute(key === "className" ? "class" : key, value)
} }
} }
function removeAttr(vnode, key, old, ns) { function removeAttr(vnode3, key, old, ns) {
if (key === "key" || key === "is" || old == null || isLifecycleMethod(key)) return if (key === "key" || key === "is" || old == null || isLifecycleMethod(key)) return
if (key[0] === "o" && key[1] === "n" && !isLifecycleMethod(key)) updateEvent(vnode, key, undefined) if (key[0] === "o" && key[1] === "n" && !isLifecycleMethod(key)) updateEvent(vnode3, key, undefined)
else if (key === "style") updateStyle(vnode.dom, old, null) else if (key === "style") updateStyle(vnode3.dom, old, null)
else if ( else if (
hasPropertyKey(vnode, key, ns) hasPropertyKey(vnode3, key, ns)
&& key !== "className" && key !== "className"
&& !(key === "value" && ( && !(key === "value" && (
vnode.tag === "option" vnode3.tag === "option"
|| vnode.tag === "select" && vnode.dom.selectedIndex === -1 && vnode.dom === activeElement() || vnode3.tag === "select" && vnode3.dom.selectedIndex === -1 && vnode3.dom === activeElement()
)) ))
&& !(vnode.tag === "input" && key === "type") && !(vnode3.tag === "input" && key === "type")
) { ) {
vnode.dom[key] = null vnode3.dom[key] = null
} else { } else {
var nsLastIndex = key.indexOf(":") var nsLastIndex = key.indexOf(":")
if (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1) if (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1)
if (old !== false) vnode.dom.removeAttribute(key === "className" ? "class" : key) if (old !== false) vnode3.dom.removeAttribute(key === "className" ? "class" : key)
} }
} }
function setLateSelectAttrs(vnode, attrs2) { function setLateSelectAttrs(vnode3, attrs2) {
if ("value" in attrs2) { if ("value" in attrs2) {
if(attrs2.value === null) { if(attrs2.value === null) {
if (vnode.dom.selectedIndex !== -1) vnode.dom.value = null if (vnode3.dom.selectedIndex !== -1) vnode3.dom.value = null
} else { } else {
var normalized = "" + attrs2.value // eslint-disable-line no-implicit-coercion var normalized = "" + attrs2.value // eslint-disable-line no-implicit-coercion
if (vnode.dom.value !== normalized || vnode.dom.selectedIndex === -1) { if (vnode3.dom.value !== normalized || vnode3.dom.selectedIndex === -1) {
vnode.dom.value = normalized vnode3.dom.value = normalized
} }
} }
} }
if ("selectedIndex" in attrs2) setAttr(vnode, "selectedIndex", null, attrs2.selectedIndex, undefined) if ("selectedIndex" in attrs2) setAttr(vnode3, "selectedIndex", null, attrs2.selectedIndex, undefined)
} }
function updateAttrs(vnode, old, attrs2, ns) { function updateAttrs(vnode3, old, attrs2, ns) {
if (attrs2 != null) { if (attrs2 != null) {
for (var key in attrs2) { for (var key in attrs2) {
setAttr(vnode, key, old && old[key], attrs2[key], ns) setAttr(vnode3, key, old && old[key], attrs2[key], ns)
} }
} }
var val var val
if (old != null) { if (old != null) {
for (var key in old) { for (var key in old) {
if (((val = old[key]) != null) && (attrs2 == null || attrs2[key] == null)) { if (((val = old[key]) != null) && (attrs2 == null || attrs2[key] == null)) {
removeAttr(vnode, key, val, ns) removeAttr(vnode3, key, val, ns)
} }
} }
} }
} }
function isFormAttribute(vnode, attr) { function isFormAttribute(vnode3, attr) {
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === activeElement() || vnode.tag === "option" && vnode.dom.parentNode === $doc.activeElement return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode3.dom === activeElement() || vnode3.tag === "option" && vnode3.dom.parentNode === $doc.activeElement
} }
function isLifecycleMethod(attr) { function isLifecycleMethod(attr) {
return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate" return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate"
} }
function hasPropertyKey(vnode, key, ns) { function hasPropertyKey(vnode3, key, ns) {
// Filter out namespaced keys // Filter out namespaced keys
return ns === undefined && ( return ns === undefined && (
// If it's a custom element, just keep it. // If it's a custom element, just keep it.
vnode.tag.indexOf("-") > -1 || vnode.attrs != null && vnode.attrs.is || vnode3.tag.indexOf("-") > -1 || vnode3.attrs != null && vnode3.attrs.is ||
// If it's a normal element, let's try to avoid a few browser bugs. // If it's a normal element, let's try to avoid a few browser bugs.
key !== "href" && key !== "list" && key !== "form" && key !== "width" && key !== "height"// && key !== "type" key !== "href" && key !== "list" && key !== "form" && key !== "width" && key !== "height"// && key !== "type"
// Defer the property check until *after* we check everything. // Defer the property check until *after* we check everything.
) && key in vnode.dom ) && key in vnode3.dom
} }
//style //style
var uppercaseRegex = /[A-Z]/g var uppercaseRegex = /[A-Z]/g
@ -1223,45 +1262,45 @@ var coreRenderer = function($window) {
} }
} }
//event //event
function updateEvent(vnode, key, value) { function updateEvent(vnode3, key, value) {
if (vnode.events != null) { if (vnode3.events != null) {
if (vnode.events[key] === value) return if (vnode3.events[key] === value) return
if (value != null && (typeof value === "function" || typeof value === "object")) { if (value != null && (typeof value === "function" || typeof value === "object")) {
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) if (vnode3.events[key] == null) vnode3.dom.addEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = value vnode3.events[key] = value
} else { } else {
if (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false) if (vnode3.events[key] != null) vnode3.dom.removeEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = undefined vnode3.events[key] = undefined
} }
} else if (value != null && (typeof value === "function" || typeof value === "object")) { } else if (value != null && (typeof value === "function" || typeof value === "object")) {
vnode.events = new EventDict() vnode3.events = new EventDict()
vnode.dom.addEventListener(key.slice(2), vnode.events, false) vnode3.dom.addEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = value vnode3.events[key] = value
} }
} }
//lifecycle //lifecycle
function initLifecycle(source, vnode, hooks) { function initLifecycle(source, vnode3, hooks) {
if (typeof source.oninit === "function") callHook.call(source.oninit, vnode) if (typeof source.oninit === "function") callHook.call(source.oninit, vnode3)
if (typeof source.oncreate === "function") hooks.push(callHook.bind(source.oncreate, vnode)) if (typeof source.oncreate === "function") hooks.push(callHook.bind(source.oncreate, vnode3))
} }
function updateLifecycle(source, vnode, hooks) { function updateLifecycle(source, vnode3, hooks) {
if (typeof source.onupdate === "function") hooks.push(callHook.bind(source.onupdate, vnode)) if (typeof source.onupdate === "function") hooks.push(callHook.bind(source.onupdate, vnode3))
} }
function shouldNotUpdate(vnode, old) { function shouldNotUpdate(vnode3, old) {
do { do {
if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") { if (vnode3.attrs != null && typeof vnode3.attrs.onbeforeupdate === "function") {
var force = callHook.call(vnode.attrs.onbeforeupdate, vnode, old) var force = callHook.call(vnode3.attrs.onbeforeupdate, vnode3, old)
if (force !== undefined && !force) break if (force !== undefined && !force) break
} }
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeupdate === "function") { if (typeof vnode3.tag !== "string" && typeof vnode3.state.onbeforeupdate === "function") {
var force = callHook.call(vnode.state.onbeforeupdate, vnode, old) var force = callHook.call(vnode3.state.onbeforeupdate, vnode3, old)
if (force !== undefined && !force) break if (force !== undefined && !force) break
} }
return false return false
} while (false); // eslint-disable-line no-constant-condition } while (false); // eslint-disable-line no-constant-condition
vnode.dom = old.dom vnode3.dom = old.dom
vnode.domSize = old.domSize vnode3.domSize = old.domSize
vnode.instance = old.instance vnode3.instance = old.instance
return true return true
} }
function render(dom, vnodes) { function render(dom, vnodes) {
@ -1291,7 +1330,7 @@ function throttle(callback) {
} }
} }
} }
var _12 = function($window, throttleMock) { var _15 = function($window, throttleMock) {
var renderService = coreRenderer($window) var renderService = coreRenderer($window)
var callbacks = [] var callbacks = []
var rendering = false var rendering = false
@ -1314,9 +1353,9 @@ var _12 = function($window, throttleMock) {
renderService.setRedraw(redraw) renderService.setRedraw(redraw)
return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render} return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}
} }
var redrawService = _12(window) var redrawService = _15(window)
requestService.setCompletionCallback(redrawService.redraw) requestService.setCompletionCallback(redrawService.redraw)
var _17 = function(redrawService0) { var _20 = function(redrawService0) {
return function(root, component) { return function(root, component) {
if (component === null) { if (component === null) {
redrawService0.render(root, []) redrawService0.render(root, [])
@ -1333,7 +1372,7 @@ var _17 = function(redrawService0) {
run0() run0()
} }
} }
m.mount = _17(redrawService) m.mount = _20(redrawService)
var Promise = PromisePolyfill var Promise = PromisePolyfill
var parseQueryString = function(string) { var parseQueryString = function(string) {
if (string === "" || string == null) return {} if (string === "" || string == null) return {}
@ -1461,7 +1500,7 @@ var coreRouter = function($window) {
} }
return router return router
} }
var _21 = function($window, redrawService0) { var _24 = function($window, redrawService0) {
var routeService = coreRouter($window) var routeService = coreRouter($window)
var identity = function(v0) {return v0} var identity = function(v0) {return v0}
var render1, component, attrs3, currentPath, lastUpdate var render1, component, attrs3, currentPath, lastUpdate
@ -1508,9 +1547,9 @@ var _21 = function($window, redrawService0) {
} }
route.get = function() {return currentPath} route.get = function() {return currentPath}
route.prefix = function(prefix) {routeService.prefix = prefix} route.prefix = function(prefix) {routeService.prefix = prefix}
var link = function(options, vnode1) { var link = function(options, vnode5) {
vnode1.dom.setAttribute("href", routeService.prefix + vnode1.attrs.href) vnode5.dom.setAttribute("href", routeService.prefix + vnode5.attrs.href)
vnode1.dom.onclick = function(e) { vnode5.dom.onclick = function(e) {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return
e.preventDefault() e.preventDefault()
e.redraw = false e.redraw = false
@ -1529,9 +1568,9 @@ var _21 = function($window, redrawService0) {
} }
return route return route
} }
m.route = _21(window, redrawService) m.route = _24(window, redrawService)
var _28 = coreRenderer(window) var _31 = coreRenderer(window)
m.render = _28.render m.render = _31.render
m.redraw = redrawService.redraw m.redraw = redrawService.redraw
m.request = requestService.request m.request = requestService.request
m.jsonp = requestService.jsonp m.jsonp = requestService.jsonp

2
mithril.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
function Vnode(tag, key, attrs0, children, text, dom) { function Vnode(tag, key, attrs0, children0, text, dom) {
return {tag: tag, key: key, attrs: attrs0, children: children, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined} return {tag: tag, key: key, attrs: attrs0, children: children0, text: text, dom: dom, domSize: undefined, state: undefined, events: undefined, instance: undefined}
} }
Vnode.normalize = function(node) { Vnode.normalize = function(node) {
if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined) if (Array.isArray(node)) return Vnode("[", undefined, undefined, Vnode.normalizeChildren(node), undefined, undefined)
@ -7,11 +7,57 @@ Vnode.normalize = function(node) {
return node return node
} }
Vnode.normalizeChildren = function(input) { Vnode.normalizeChildren = function(input) {
var children = [] var children0 = []
for (var i = 0; i < input.length; i++) { for (var i = 0; i < input.length; i++) {
children[i] = Vnode.normalize(input[i]) children0[i] = Vnode.normalize(input[i])
} }
return children return children0
}
// Call via `hyperscriptVnode0.apply(startOffset, arguments)`
//
// The reason I do it this way, forwarding the arguments and passing the start
// offset in `this`, is so I don't have to create a temporary array in a
// performance-critical path.
//
// In native ES6, I'd instead add a final `...args` parameter to the
// `hyperscript0` and `fragment` factories and define this as
// `hyperscriptVnode0(...args)`, since modern engines do optimize that away. But
// ES5 (what Mithril requires thanks to IE support) doesn't give me that luxury,
// and engines aren't nearly intelligent enough to do either of these:
//
// 1. Elide the allocation for `[].slice.call(arguments, 1)` when it's passed to
// another function only to be indexed.
// 2. Elide an `arguments` allocation when it's passed to any function other
// than `Function.prototype.apply` or `Reflect.apply`.
//
// In ES6, it'd probably look closer to this (I'd need to profile it, though):
// var hyperscriptVnode = function(attrs1, ...children1) {
// if (attrs1 == null || typeof attrs1 === "object" && attrs1.tag == null && !Array.isArray(attrs1)) {
// if (children1.length === 1 && Array.isArray(children1[0])) children1 = children1[0]
// } else {
// children1 = children1.length === 0 && Array.isArray(attrs1) ? attrs1 : [attrs1, ...children1]
// attrs1 = undefined
// }
//
// if (attrs1 == null) attrs1 = {}
// return Vnode("", attrs1.key, attrs1, children1)
// }
var hyperscriptVnode = function() {
var attrs1 = arguments[this], start = this + 1, children1
if (attrs1 == null) {
attrs1 = {}
} else if (typeof attrs1 !== "object" || attrs1.tag != null || Array.isArray(attrs1)) {
attrs1 = {}
start = this
}
if (arguments.length === start + 1) {
children1 = arguments[start]
if (!Array.isArray(children1)) children1 = [children1]
} else {
children1 = []
while (start < arguments.length) children1.push(arguments[start++])
}
return Vnode("", attrs1.key, attrs1, children1)
} }
var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g
var selectorCache = {} var selectorCache = {}
@ -37,16 +83,18 @@ function compileSelector(selector) {
if (classes.length > 0) attrs.className = classes.join(" ") if (classes.length > 0) attrs.className = classes.join(" ")
return selectorCache[selector] = {tag: tag, attrs: attrs} return selectorCache[selector] = {tag: tag, attrs: attrs}
} }
function execSelector(state, attrs, children) { function execSelector(state, vnode) {
var hasAttrs = false, childList, text var attrs = vnode.attrs
var classAttr = hasOwn.call(attrs, "class") ? "class" : "className" var children = Vnode.normalizeChildren(vnode.children)
var className = attrs[classAttr] var hasClass = hasOwn.call(attrs, "class")
var className = hasClass ? attrs.class : attrs.className
vnode.tag = state.tag
vnode.attrs = null
vnode.children = undefined
if (!isEmpty(state.attrs) && !isEmpty(attrs)) { if (!isEmpty(state.attrs) && !isEmpty(attrs)) {
var newAttrs = {} var newAttrs = {}
for(var key in attrs) { for (var key in attrs) {
if (hasOwn.call(attrs, key)) { if (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key]
newAttrs[key] = attrs[key]
}
} }
attrs = newAttrs attrs = newAttrs
} }
@ -63,50 +111,41 @@ function execSelector(state, attrs, children) {
: state.attrs.className != null : state.attrs.className != null
? state.attrs.className ? state.attrs.className
: null : null
if (classAttr === "class") attrs.class = null if (hasClass) attrs.class = null
for (var key in attrs) { for (var key in attrs) {
if (hasOwn.call(attrs, key) && key !== "key") { if (hasOwn.call(attrs, key) && key !== "key") {
hasAttrs = true vnode.attrs = attrs
break break
} }
} }
if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") { if (Array.isArray(children) && children.length === 1 && children[0] != null && children[0].tag === "#") {
text = children[0].children vnode.text = children[0].children
} else { } else {
childList = children vnode.children = children
} }
return Vnode(state.tag, attrs.key, hasAttrs ? attrs : null, childList, text) return vnode
} }
function hyperscript(selector) { function hyperscript(selector) {
if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") { if (selector == null || typeof selector !== "string" && typeof selector !== "function" && typeof selector.view !== "function") {
throw Error("The selector must be either a string or a component."); throw Error("The selector must be either a string or a component.");
} }
var attrs = arguments[1], start = 2, children var vnode = hyperscriptVnode.apply(1, arguments)
if (attrs == null) {
attrs = {}
} else if (typeof attrs !== "object" || attrs.tag != null || Array.isArray(attrs)) {
attrs = {}
start = 1
}
if (arguments.length === start + 1) {
children = arguments[start]
if (!Array.isArray(children)) children = [children]
} else {
children = []
while (start < arguments.length) children.push(arguments[start++])
}
if (typeof selector === "string") { if (typeof selector === "string") {
return execSelector(selectorCache[selector] || compileSelector(selector), attrs, Vnode.normalizeChildren(children)) return execSelector(selectorCache[selector] || compileSelector(selector), vnode)
} else { } else {
return Vnode(selector, attrs.key, attrs, children) vnode.tag = selector
return vnode
} }
} }
hyperscript.trust = function(html) { hyperscript.trust = function(html) {
if (html == null) html = "" if (html == null) html = ""
return Vnode("<", undefined, undefined, html, undefined, undefined) return Vnode("<", undefined, undefined, html, undefined, undefined)
} }
hyperscript.fragment = function(attrs1, children0) { hyperscript.fragment = function() {
return Vnode("[", attrs1.key, attrs1, Vnode.normalizeChildren(children0), undefined, undefined) var vnode2 = hyperscriptVnode.apply(0, arguments)
vnode2.tag = "["
vnode2.children = Vnode.normalizeChildren(vnode2.children)
return vnode2
} }
var m = function m() { return hyperscript.apply(this, arguments) } var m = function m() { return hyperscript.apply(this, arguments) }
m.m = hyperscript m.m = hyperscript
@ -256,7 +295,7 @@ var buildQueryString = function(object) {
else args.push(encodeURIComponent(key) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : "")) else args.push(encodeURIComponent(key) + (value != null && value !== "" ? "=" + encodeURIComponent(value) : ""))
} }
} }
var _9 = function($window, Promise) { var _12 = function($window, Promise) {
var callbackCount = 0 var callbackCount = 0
var oncompletion var oncompletion
function makeRequest(factory) { function makeRequest(factory) {
@ -404,7 +443,7 @@ var _9 = function($window, Promise) {
}, },
} }
} }
var requestService = _9(window, PromisePolyfill) var requestService = _12(window, PromisePolyfill)
var coreRenderer = function($window) { var coreRenderer = function($window) {
var $doc = $window.document var $doc = $window.document
var nameSpace = { var nameSpace = {
@ -413,23 +452,23 @@ var coreRenderer = function($window) {
} }
var redraw0 var redraw0
function setRedraw(callback) {return redraw0 = callback} function setRedraw(callback) {return redraw0 = callback}
function getNameSpace(vnode) { function getNameSpace(vnode3) {
return vnode.attrs && vnode.attrs.xmlns || nameSpace[vnode.tag] return vnode3.attrs && vnode3.attrs.xmlns || nameSpace[vnode3.tag]
} }
//sanity check to discourage people from doing `vnode.state = ...` //sanity check to discourage people from doing `vnode3.state = ...`
function checkState(vnode, original) { function checkState(vnode3, original) {
if (vnode.state !== original) throw new Error("`vnode.state` must not be modified") if (vnode3.state !== original) throw new Error("`vnode.state` must not be modified")
} }
//Note: the hook is passed as the `this` argument to allow proxying the //Note: the hook is passed as the `this` argument to allow proxying the
//arguments without requiring a full array allocation to do so. It also //arguments without requiring a full array allocation to do so. It also
//takes advantage of the fact the current `vnode` is the first argument in //takes advantage of the fact the current `vnode3` is the first argument in
//all lifecycle methods. //all lifecycle methods.
function callHook(vnode) { function callHook(vnode3) {
var original = vnode.state var original = vnode3.state
try { try {
return this.apply(original, arguments) return this.apply(original, arguments)
} finally { } finally {
checkState(vnode, original) checkState(vnode3, original)
} }
} }
// IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when // IE11 (at least) throws an UnspecifiedError when accessing document.activeElement when
@ -444,33 +483,33 @@ var coreRenderer = function($window) {
//create //create
function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) { function createNodes(parent, vnodes, start, end, hooks, nextSibling, ns) {
for (var i = start; i < end; i++) { for (var i = start; i < end; i++) {
var vnode = vnodes[i] var vnode3 = vnodes[i]
if (vnode != null) { if (vnode3 != null) {
createNode(parent, vnode, hooks, ns, nextSibling) createNode(parent, vnode3, hooks, ns, nextSibling)
} }
} }
} }
function createNode(parent, vnode, hooks, ns, nextSibling) { function createNode(parent, vnode3, hooks, ns, nextSibling) {
var tag = vnode.tag var tag = vnode3.tag
if (typeof tag === "string") { if (typeof tag === "string") {
vnode.state = {} vnode3.state = {}
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) initLifecycle(vnode3.attrs, vnode3, hooks)
switch (tag) { switch (tag) {
case "#": createText(parent, vnode, nextSibling); break case "#": createText(parent, vnode3, nextSibling); break
case "<": createHTML(parent, vnode, ns, nextSibling); break case "<": createHTML(parent, vnode3, ns, nextSibling); break
case "[": createFragment(parent, vnode, hooks, ns, nextSibling); break case "[": createFragment(parent, vnode3, hooks, ns, nextSibling); break
default: createElement(parent, vnode, hooks, ns, nextSibling) default: createElement(parent, vnode3, hooks, ns, nextSibling)
} }
} }
else createComponent(parent, vnode, hooks, ns, nextSibling) else createComponent(parent, vnode3, hooks, ns, nextSibling)
} }
function createText(parent, vnode, nextSibling) { function createText(parent, vnode3, nextSibling) {
vnode.dom = $doc.createTextNode(vnode.children) vnode3.dom = $doc.createTextNode(vnode3.children)
insertNode(parent, vnode.dom, nextSibling) insertNode(parent, vnode3.dom, nextSibling)
} }
var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"} var possibleParents = {caption: "table", thead: "table", tbody: "table", tfoot: "table", tr: "tbody", th: "tr", td: "tr", colgroup: "table", col: "colgroup"}
function createHTML(parent, vnode, ns, nextSibling) { function createHTML(parent, vnode3, ns, nextSibling) {
var match0 = vnode.children.match(/^\s*?<(\w+)/im) || [] var match0 = vnode3.children.match(/^\s*?<(\w+)/im) || []
// not using the proper parent makes the child element(s) vanish. // not using the proper parent makes the child element(s) vanish.
// var div = document.createElement("div") // var div = document.createElement("div")
// div.innerHTML = "<td>i</td><td>j</td>" // div.innerHTML = "<td>i</td><td>j</td>"
@ -478,13 +517,13 @@ var coreRenderer = function($window) {
// --> "ij", no <td> in sight. // --> "ij", no <td> in sight.
var temp = $doc.createElement(possibleParents[match0[1]] || "div") var temp = $doc.createElement(possibleParents[match0[1]] || "div")
if (ns === "http://www.w3.org/2000/svg") { if (ns === "http://www.w3.org/2000/svg") {
temp.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + vnode.children + "</svg>" temp.innerHTML = "<svg xmlns=\"http://www.w3.org/2000/svg\">" + vnode3.children + "</svg>"
temp = temp.firstChild temp = temp.firstChild
} else { } else {
temp.innerHTML = vnode.children temp.innerHTML = vnode3.children
} }
vnode.dom = temp.firstChild vnode3.dom = temp.firstChild
vnode.domSize = temp.childNodes.length vnode3.domSize = temp.childNodes.length
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
var child var child
while (child = temp.firstChild) { while (child = temp.firstChild) {
@ -492,73 +531,73 @@ var coreRenderer = function($window) {
} }
insertNode(parent, fragment, nextSibling) insertNode(parent, fragment, nextSibling)
} }
function createFragment(parent, vnode, hooks, ns, nextSibling) { function createFragment(parent, vnode3, hooks, ns, nextSibling) {
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
if (vnode.children != null) { if (vnode3.children != null) {
var children1 = vnode.children var children3 = vnode3.children
createNodes(fragment, children1, 0, children1.length, hooks, null, ns) createNodes(fragment, children3, 0, children3.length, hooks, null, ns)
} }
vnode.dom = fragment.firstChild vnode3.dom = fragment.firstChild
vnode.domSize = fragment.childNodes.length vnode3.domSize = fragment.childNodes.length
insertNode(parent, fragment, nextSibling) insertNode(parent, fragment, nextSibling)
} }
function createElement(parent, vnode, hooks, ns, nextSibling) { function createElement(parent, vnode3, hooks, ns, nextSibling) {
var tag = vnode.tag var tag = vnode3.tag
var attrs2 = vnode.attrs var attrs2 = vnode3.attrs
var is = attrs2 && attrs2.is var is = attrs2 && attrs2.is
ns = getNameSpace(vnode) || ns ns = getNameSpace(vnode3) || ns
var element = ns ? var element = ns ?
is ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) : is ? $doc.createElementNS(ns, tag, {is: is}) : $doc.createElementNS(ns, tag) :
is ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag) is ? $doc.createElement(tag, {is: is}) : $doc.createElement(tag)
vnode.dom = element vnode3.dom = element
if (attrs2 != null) { if (attrs2 != null) {
setAttrs(vnode, attrs2, ns) setAttrs(vnode3, attrs2, ns)
} }
insertNode(parent, element, nextSibling) insertNode(parent, element, nextSibling)
if (attrs2 != null && attrs2.contenteditable != null) { if (attrs2 != null && attrs2.contenteditable != null) {
setContentEditable(vnode) setContentEditable(vnode3)
} }
else { else {
if (vnode.text != null) { if (vnode3.text != null) {
if (vnode.text !== "") element.textContent = vnode.text if (vnode3.text !== "") element.textContent = vnode3.text
else vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] else vnode3.children = [Vnode("#", undefined, undefined, vnode3.text, undefined, undefined)]
} }
if (vnode.children != null) { if (vnode3.children != null) {
var children1 = vnode.children var children3 = vnode3.children
createNodes(element, children1, 0, children1.length, hooks, null, ns) createNodes(element, children3, 0, children3.length, hooks, null, ns)
if (vnode.tag === "select" && attrs2 != null) setLateSelectAttrs(vnode, attrs2) if (vnode3.tag === "select" && attrs2 != null) setLateSelectAttrs(vnode3, attrs2)
} }
} }
} }
function initComponent(vnode, hooks) { function initComponent(vnode3, hooks) {
var sentinel var sentinel
if (typeof vnode.tag.view === "function") { if (typeof vnode3.tag.view === "function") {
vnode.state = Object.create(vnode.tag) vnode3.state = Object.create(vnode3.tag)
sentinel = vnode.state.view sentinel = vnode3.state.view
if (sentinel.$$reentrantLock$$ != null) return if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true sentinel.$$reentrantLock$$ = true
} else { } else {
vnode.state = void 0 vnode3.state = void 0
sentinel = vnode.tag sentinel = vnode3.tag
if (sentinel.$$reentrantLock$$ != null) return if (sentinel.$$reentrantLock$$ != null) return
sentinel.$$reentrantLock$$ = true sentinel.$$reentrantLock$$ = true
vnode.state = (vnode.tag.prototype != null && typeof vnode.tag.prototype.view === "function") ? new vnode.tag(vnode) : vnode.tag(vnode) vnode3.state = (vnode3.tag.prototype != null && typeof vnode3.tag.prototype.view === "function") ? new vnode3.tag(vnode3) : vnode3.tag(vnode3)
} }
initLifecycle(vnode.state, vnode, hooks) initLifecycle(vnode3.state, vnode3, hooks)
if (vnode.attrs != null) initLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) initLifecycle(vnode3.attrs, vnode3, hooks)
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode)) vnode3.instance = Vnode.normalize(callHook.call(vnode3.state.view, vnode3))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument") if (vnode3.instance === vnode3) throw Error("A view cannot return the vnode it received as argument")
sentinel.$$reentrantLock$$ = null sentinel.$$reentrantLock$$ = null
} }
function createComponent(parent, vnode, hooks, ns, nextSibling) { function createComponent(parent, vnode3, hooks, ns, nextSibling) {
initComponent(vnode, hooks) initComponent(vnode3, hooks)
if (vnode.instance != null) { if (vnode3.instance != null) {
createNode(parent, vnode.instance, hooks, ns, nextSibling) createNode(parent, vnode3.instance, hooks, ns, nextSibling)
vnode.dom = vnode.instance.dom vnode3.dom = vnode3.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0 vnode3.domSize = vnode3.dom != null ? vnode3.instance.domSize : 0
} }
else { else {
vnode.domSize = 0 vnode3.domSize = 0
} }
} }
//update //update
@ -608,7 +647,7 @@ var coreRenderer = function($window) {
// 4) figure out what nodes in 1) to move in order to minimize the DOM operations. // 4) figure out what nodes in 1) to move in order to minimize the DOM operations.
// //
// To achieve 1) one can create a dictionary of keys => index0 (for the old list), then1 iterate // To achieve 1) one can create a dictionary of keys => index0 (for the old list), then1 iterate
// over the new list and for each new vnode, find the corresponding vnode in the old list using // over the new list and for each new vnode3, find the corresponding vnode3 in the old list using
// the map. // the map.
// 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new // 2) is achieved in the same step: if a new node has no corresponding entry in the map, it is new
// and must be created. // and must be created.
@ -642,7 +681,7 @@ var coreRenderer = function($window) {
// //
// `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations. // `updateNode()` and `createNode()` expect a nextSibling parameter to perform DOM operations.
// When the list is being traversed top-down, at any index0, the DOM nodes up to the previous // When the list is being traversed top-down, at any index0, the DOM nodes up to the previous
// vnode reflect the content of the new list, whereas the rest of the DOM nodes reflect the old // vnode3 reflect the content of the new list, whereas the rest of the DOM nodes reflect the old
// list. The next0 sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`. // list. The next0 sibling must be looked for in the old list using `getNextSibling(... oldStart + 1 ...)`.
// //
// In the other scenarios (swaps, upwards traversal, map-based diff), // In the other scenarios (swaps, upwards traversal, map-based diff),
@ -817,108 +856,108 @@ var coreRenderer = function($window) {
} }
} }
} }
function updateNode(parent, old, vnode, hooks, nextSibling, ns) { function updateNode(parent, old, vnode3, hooks, nextSibling, ns) {
var oldTag = old.tag, tag = vnode.tag var oldTag = old.tag, tag = vnode3.tag
if (oldTag === tag) { if (oldTag === tag) {
vnode.state = old.state vnode3.state = old.state
vnode.events = old.events vnode3.events = old.events
if (shouldNotUpdate(vnode, old)) return if (shouldNotUpdate(vnode3, old)) return
if (typeof oldTag === "string") { if (typeof oldTag === "string") {
if (vnode.attrs != null) { if (vnode3.attrs != null) {
updateLifecycle(vnode.attrs, vnode, hooks) updateLifecycle(vnode3.attrs, vnode3, hooks)
} }
switch (oldTag) { switch (oldTag) {
case "#": updateText(old, vnode); break case "#": updateText(old, vnode3); break
case "<": updateHTML(parent, old, vnode, ns, nextSibling); break case "<": updateHTML(parent, old, vnode3, ns, nextSibling); break
case "[": updateFragment(parent, old, vnode, hooks, nextSibling, ns); break case "[": updateFragment(parent, old, vnode3, hooks, nextSibling, ns); break
default: updateElement(old, vnode, hooks, ns) default: updateElement(old, vnode3, hooks, ns)
} }
} }
else updateComponent(parent, old, vnode, hooks, nextSibling, ns) else updateComponent(parent, old, vnode3, hooks, nextSibling, ns)
} }
else { else {
removeNode(old) removeNode(old)
createNode(parent, vnode, hooks, ns, nextSibling) createNode(parent, vnode3, hooks, ns, nextSibling)
} }
} }
function updateText(old, vnode) { function updateText(old, vnode3) {
if (old.children.toString() !== vnode.children.toString()) { if (old.children.toString() !== vnode3.children.toString()) {
old.dom.nodeValue = vnode.children old.dom.nodeValue = vnode3.children
} }
vnode.dom = old.dom vnode3.dom = old.dom
} }
function updateHTML(parent, old, vnode, ns, nextSibling) { function updateHTML(parent, old, vnode3, ns, nextSibling) {
if (old.children !== vnode.children) { if (old.children !== vnode3.children) {
toFragment(old) toFragment(old)
createHTML(parent, vnode, ns, nextSibling) createHTML(parent, vnode3, ns, nextSibling)
} }
else vnode.dom = old.dom, vnode.domSize = old.domSize else vnode3.dom = old.dom, vnode3.domSize = old.domSize
} }
function updateFragment(parent, old, vnode, hooks, nextSibling, ns) { function updateFragment(parent, old, vnode3, hooks, nextSibling, ns) {
updateNodes(parent, old.children, vnode.children, hooks, nextSibling, ns) updateNodes(parent, old.children, vnode3.children, hooks, nextSibling, ns)
var domSize = 0, children1 = vnode.children var domSize = 0, children3 = vnode3.children
vnode.dom = null vnode3.dom = null
if (children1 != null) { if (children3 != null) {
for (var i = 0; i < children1.length; i++) { for (var i = 0; i < children3.length; i++) {
var child = children1[i] var child = children3[i]
if (child != null && child.dom != null) { if (child != null && child.dom != null) {
if (vnode.dom == null) vnode.dom = child.dom if (vnode3.dom == null) vnode3.dom = child.dom
domSize += child.domSize || 1 domSize += child.domSize || 1
} }
} }
if (domSize !== 1) vnode.domSize = domSize if (domSize !== 1) vnode3.domSize = domSize
} }
} }
function updateElement(old, vnode, hooks, ns) { function updateElement(old, vnode3, hooks, ns) {
var element = vnode.dom = old.dom var element = vnode3.dom = old.dom
ns = getNameSpace(vnode) || ns ns = getNameSpace(vnode3) || ns
if (vnode.tag === "textarea") { if (vnode3.tag === "textarea") {
if (vnode.attrs == null) vnode.attrs = {} if (vnode3.attrs == null) vnode3.attrs = {}
if (vnode.text != null) { if (vnode3.text != null) {
vnode.attrs.value = vnode.text //FIXME handle0 multiple children1 vnode3.attrs.value = vnode3.text //FIXME handle0 multiple children3
vnode.text = undefined vnode3.text = undefined
} }
} }
updateAttrs(vnode, old.attrs, vnode.attrs, ns) updateAttrs(vnode3, old.attrs, vnode3.attrs, ns)
if (vnode.attrs != null && vnode.attrs.contenteditable != null) { if (vnode3.attrs != null && vnode3.attrs.contenteditable != null) {
setContentEditable(vnode) setContentEditable(vnode3)
} }
else if (old.text != null && vnode.text != null && vnode.text !== "") { else if (old.text != null && vnode3.text != null && vnode3.text !== "") {
if (old.text.toString() !== vnode.text.toString()) old.dom.firstChild.nodeValue = vnode.text if (old.text.toString() !== vnode3.text.toString()) old.dom.firstChild.nodeValue = vnode3.text
} }
else { else {
if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)] if (old.text != null) old.children = [Vnode("#", undefined, undefined, old.text, undefined, old.dom.firstChild)]
if (vnode.text != null) vnode.children = [Vnode("#", undefined, undefined, vnode.text, undefined, undefined)] if (vnode3.text != null) vnode3.children = [Vnode("#", undefined, undefined, vnode3.text, undefined, undefined)]
updateNodes(element, old.children, vnode.children, hooks, null, ns) updateNodes(element, old.children, vnode3.children, hooks, null, ns)
} }
} }
function updateComponent(parent, old, vnode, hooks, nextSibling, ns) { function updateComponent(parent, old, vnode3, hooks, nextSibling, ns) {
vnode.instance = Vnode.normalize(callHook.call(vnode.state.view, vnode)) vnode3.instance = Vnode.normalize(callHook.call(vnode3.state.view, vnode3))
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as argument") if (vnode3.instance === vnode3) throw Error("A view cannot return the vnode it received as argument")
updateLifecycle(vnode.state, vnode, hooks) updateLifecycle(vnode3.state, vnode3, hooks)
if (vnode.attrs != null) updateLifecycle(vnode.attrs, vnode, hooks) if (vnode3.attrs != null) updateLifecycle(vnode3.attrs, vnode3, hooks)
if (vnode.instance != null) { if (vnode3.instance != null) {
if (old.instance == null) createNode(parent, vnode.instance, hooks, ns, nextSibling) if (old.instance == null) createNode(parent, vnode3.instance, hooks, ns, nextSibling)
else updateNode(parent, old.instance, vnode.instance, hooks, nextSibling, ns) else updateNode(parent, old.instance, vnode3.instance, hooks, nextSibling, ns)
vnode.dom = vnode.instance.dom vnode3.dom = vnode3.instance.dom
vnode.domSize = vnode.instance.domSize vnode3.domSize = vnode3.instance.domSize
} }
else if (old.instance != null) { else if (old.instance != null) {
removeNode(old.instance) removeNode(old.instance)
vnode.dom = undefined vnode3.dom = undefined
vnode.domSize = 0 vnode3.domSize = 0
} }
else { else {
vnode.dom = old.dom vnode3.dom = old.dom
vnode.domSize = old.domSize vnode3.domSize = old.domSize
} }
} }
function getKeyMap(vnodes, start, end) { function getKeyMap(vnodes, start, end) {
var map = Object.create(null) var map = Object.create(null)
for (; start < end; start++) { for (; start < end; start++) {
var vnode = vnodes[start] var vnode3 = vnodes[start]
if (vnode != null) { if (vnode3 != null) {
var key = vnode.key var key = vnode3.key
if (key != null) map[key] = start if (key != null) map[key] = start
} }
} }
@ -971,18 +1010,18 @@ var coreRenderer = function($window) {
} }
return result return result
} }
function toFragment(vnode) { function toFragment(vnode3) {
var count0 = vnode.domSize var count0 = vnode3.domSize
if (count0 != null || vnode.dom == null) { if (count0 != null || vnode3.dom == null) {
var fragment = $doc.createDocumentFragment() var fragment = $doc.createDocumentFragment()
if (count0 > 0) { if (count0 > 0) {
var dom = vnode.dom var dom = vnode3.dom
while (--count0) fragment.appendChild(dom.nextSibling) while (--count0) fragment.appendChild(dom.nextSibling)
fragment.insertBefore(dom, fragment.firstChild) fragment.insertBefore(dom, fragment.firstChild)
} }
return fragment return fragment
} }
else return vnode.dom else return vnode3.dom
} }
function getNextSibling(vnodes, i, nextSibling) { function getNextSibling(vnodes, i, nextSibling) {
for (; i < vnodes.length; i++) { for (; i < vnodes.length; i++) {
@ -994,33 +1033,33 @@ var coreRenderer = function($window) {
if (nextSibling != null) parent.insertBefore(dom, nextSibling) if (nextSibling != null) parent.insertBefore(dom, nextSibling)
else parent.appendChild(dom) else parent.appendChild(dom)
} }
function setContentEditable(vnode) { function setContentEditable(vnode3) {
var children1 = vnode.children var children3 = vnode3.children
if (children1 != null && children1.length === 1 && children1[0].tag === "<") { if (children3 != null && children3.length === 1 && children3[0].tag === "<") {
var content = children1[0].children var content = children3[0].children
if (vnode.dom.innerHTML !== content) vnode.dom.innerHTML = content if (vnode3.dom.innerHTML !== content) vnode3.dom.innerHTML = content
} }
else if (vnode.text != null || children1 != null && children1.length !== 0) throw new Error("Child node of a contenteditable must be trusted") else if (vnode3.text != null || children3 != null && children3.length !== 0) throw new Error("Child node of a contenteditable must be trusted")
} }
//remove //remove
function removeNodes(vnodes, start, end) { function removeNodes(vnodes, start, end) {
for (var i = start; i < end; i++) { for (var i = start; i < end; i++) {
var vnode = vnodes[i] var vnode3 = vnodes[i]
if (vnode != null) removeNode(vnode) if (vnode3 != null) removeNode(vnode3)
} }
} }
function removeNode(vnode) { function removeNode(vnode3) {
var expected = 1, called = 0 var expected = 1, called = 0
var original = vnode.state var original = vnode3.state
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeremove === "function") { if (typeof vnode3.tag !== "string" && typeof vnode3.state.onbeforeremove === "function") {
var result = callHook.call(vnode.state.onbeforeremove, vnode) var result = callHook.call(vnode3.state.onbeforeremove, vnode3)
if (result != null && typeof result.then === "function") { if (result != null && typeof result.then === "function") {
expected++ expected++
result.then(continuation, continuation) result.then(continuation, continuation)
} }
} }
if (vnode.attrs && typeof vnode.attrs.onbeforeremove === "function") { if (vnode3.attrs && typeof vnode3.attrs.onbeforeremove === "function") {
var result = callHook.call(vnode.attrs.onbeforeremove, vnode) var result = callHook.call(vnode3.attrs.onbeforeremove, vnode3)
if (result != null && typeof result.then === "function") { if (result != null && typeof result.then === "function") {
expected++ expected++
result.then(continuation, continuation) result.then(continuation, continuation)
@ -1029,129 +1068,129 @@ var coreRenderer = function($window) {
continuation() continuation()
function continuation() { function continuation() {
if (++called === expected) { if (++called === expected) {
checkState(vnode, original) checkState(vnode3, original)
onremove(vnode) onremove(vnode3)
if (vnode.dom) { if (vnode3.dom) {
var parent = vnode.dom.parentNode var parent = vnode3.dom.parentNode
var count0 = vnode.domSize || 1 var count0 = vnode3.domSize || 1
while (--count0) parent.removeChild(vnode.dom.nextSibling) while (--count0) parent.removeChild(vnode3.dom.nextSibling)
parent.removeChild(vnode.dom) parent.removeChild(vnode3.dom)
} }
} }
} }
} }
function onremove(vnode) { function onremove(vnode3) {
if (typeof vnode.tag !== "string" && typeof vnode.state.onremove === "function") callHook.call(vnode.state.onremove, vnode) if (typeof vnode3.tag !== "string" && typeof vnode3.state.onremove === "function") callHook.call(vnode3.state.onremove, vnode3)
if (vnode.attrs && typeof vnode.attrs.onremove === "function") callHook.call(vnode.attrs.onremove, vnode) if (vnode3.attrs && typeof vnode3.attrs.onremove === "function") callHook.call(vnode3.attrs.onremove, vnode3)
if (typeof vnode.tag !== "string") { if (typeof vnode3.tag !== "string") {
if (vnode.instance != null) onremove(vnode.instance) if (vnode3.instance != null) onremove(vnode3.instance)
} else { } else {
var children1 = vnode.children var children3 = vnode3.children
if (Array.isArray(children1)) { if (Array.isArray(children3)) {
for (var i = 0; i < children1.length; i++) { for (var i = 0; i < children3.length; i++) {
var child = children1[i] var child = children3[i]
if (child != null) onremove(child) if (child != null) onremove(child)
} }
} }
} }
} }
//attrs2 //attrs2
function setAttrs(vnode, attrs2, ns) { function setAttrs(vnode3, attrs2, ns) {
for (var key in attrs2) { for (var key in attrs2) {
setAttr(vnode, key, null, attrs2[key], ns) setAttr(vnode3, key, null, attrs2[key], ns)
} }
} }
function setAttr(vnode, key, old, value, ns) { function setAttr(vnode3, key, old, value, ns) {
if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode, key)) && typeof value !== "object") return if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode3, key)) && typeof value !== "object") return
if (key[0] === "o" && key[1] === "n") return updateEvent(vnode, key, value) if (key[0] === "o" && key[1] === "n") return updateEvent(vnode3, key, value)
if (key.slice(0, 6) === "xlink:") vnode.dom.setAttributeNS("http://www.w3.org/1999/xlink", key.slice(6), value) if (key.slice(0, 6) === "xlink:") vnode3.dom.setAttributeNS("http://www.w3.org/1999/xlink", key.slice(6), value)
else if (key === "style") updateStyle(vnode.dom, old, value) else if (key === "style") updateStyle(vnode3.dom, old, value)
else if (hasPropertyKey(vnode, key, ns)) { else if (hasPropertyKey(vnode3, key, ns)) {
if (key === "value") { if (key === "value") {
// Only do the coercion if we're actually going to check the value. // Only do the coercion if we're actually going to check the value.
/* eslint-disable no-implicit-coercion */ /* eslint-disable no-implicit-coercion */
//setting input[value] to same value by typing on focused element moves cursor to end in Chrome //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 === "" + value && vnode.dom === activeElement()) return if ((vnode3.tag === "input" || vnode3.tag === "textarea") && vnode3.dom.value === "" + value && vnode3.dom === activeElement()) return
//setting select[value] to same value while having select open blinks select dropdown in Chrome //setting select[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "select" && old !== null && vnode.dom.value === "" + value) return if (vnode3.tag === "select" && old !== null && vnode3.dom.value === "" + value) return
//setting option[value] to same value while having select open blinks select dropdown in Chrome //setting option[value] to same value while having select open blinks select dropdown in Chrome
if (vnode.tag === "option" && old !== null && vnode.dom.value === "" + value) return if (vnode3.tag === "option" && old !== null && vnode3.dom.value === "" + value) return
/* eslint-enable no-implicit-coercion */ /* eslint-enable no-implicit-coercion */
} }
// If you assign an input type1 that is not supported by IE 11 with an assignment expression, an error1 will occur. // If you assign an input type1 that is not supported by IE 11 with an assignment expression, an error1 will occur.
if (vnode.tag === "input" && key === "type") vnode.dom.setAttribute(key, value) if (vnode3.tag === "input" && key === "type") vnode3.dom.setAttribute(key, value)
else vnode.dom[key] = value else vnode3.dom[key] = value
} else { } else {
if (typeof value === "boolean") { if (typeof value === "boolean") {
if (value) vnode.dom.setAttribute(key, "") if (value) vnode3.dom.setAttribute(key, "")
else vnode.dom.removeAttribute(key) else vnode3.dom.removeAttribute(key)
} }
else vnode.dom.setAttribute(key === "className" ? "class" : key, value) else vnode3.dom.setAttribute(key === "className" ? "class" : key, value)
} }
} }
function removeAttr(vnode, key, old, ns) { function removeAttr(vnode3, key, old, ns) {
if (key === "key" || key === "is" || old == null || isLifecycleMethod(key)) return if (key === "key" || key === "is" || old == null || isLifecycleMethod(key)) return
if (key[0] === "o" && key[1] === "n" && !isLifecycleMethod(key)) updateEvent(vnode, key, undefined) if (key[0] === "o" && key[1] === "n" && !isLifecycleMethod(key)) updateEvent(vnode3, key, undefined)
else if (key === "style") updateStyle(vnode.dom, old, null) else if (key === "style") updateStyle(vnode3.dom, old, null)
else if ( else if (
hasPropertyKey(vnode, key, ns) hasPropertyKey(vnode3, key, ns)
&& key !== "className" && key !== "className"
&& !(key === "value" && ( && !(key === "value" && (
vnode.tag === "option" vnode3.tag === "option"
|| vnode.tag === "select" && vnode.dom.selectedIndex === -1 && vnode.dom === activeElement() || vnode3.tag === "select" && vnode3.dom.selectedIndex === -1 && vnode3.dom === activeElement()
)) ))
&& !(vnode.tag === "input" && key === "type") && !(vnode3.tag === "input" && key === "type")
) { ) {
vnode.dom[key] = null vnode3.dom[key] = null
} else { } else {
var nsLastIndex = key.indexOf(":") var nsLastIndex = key.indexOf(":")
if (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1) if (nsLastIndex !== -1) key = key.slice(nsLastIndex + 1)
if (old !== false) vnode.dom.removeAttribute(key === "className" ? "class" : key) if (old !== false) vnode3.dom.removeAttribute(key === "className" ? "class" : key)
} }
} }
function setLateSelectAttrs(vnode, attrs2) { function setLateSelectAttrs(vnode3, attrs2) {
if ("value" in attrs2) { if ("value" in attrs2) {
if(attrs2.value === null) { if(attrs2.value === null) {
if (vnode.dom.selectedIndex !== -1) vnode.dom.value = null if (vnode3.dom.selectedIndex !== -1) vnode3.dom.value = null
} else { } else {
var normalized = "" + attrs2.value // eslint-disable-line no-implicit-coercion var normalized = "" + attrs2.value // eslint-disable-line no-implicit-coercion
if (vnode.dom.value !== normalized || vnode.dom.selectedIndex === -1) { if (vnode3.dom.value !== normalized || vnode3.dom.selectedIndex === -1) {
vnode.dom.value = normalized vnode3.dom.value = normalized
} }
} }
} }
if ("selectedIndex" in attrs2) setAttr(vnode, "selectedIndex", null, attrs2.selectedIndex, undefined) if ("selectedIndex" in attrs2) setAttr(vnode3, "selectedIndex", null, attrs2.selectedIndex, undefined)
} }
function updateAttrs(vnode, old, attrs2, ns) { function updateAttrs(vnode3, old, attrs2, ns) {
if (attrs2 != null) { if (attrs2 != null) {
for (var key in attrs2) { for (var key in attrs2) {
setAttr(vnode, key, old && old[key], attrs2[key], ns) setAttr(vnode3, key, old && old[key], attrs2[key], ns)
} }
} }
var val var val
if (old != null) { if (old != null) {
for (var key in old) { for (var key in old) {
if (((val = old[key]) != null) && (attrs2 == null || attrs2[key] == null)) { if (((val = old[key]) != null) && (attrs2 == null || attrs2[key] == null)) {
removeAttr(vnode, key, val, ns) removeAttr(vnode3, key, val, ns)
} }
} }
} }
} }
function isFormAttribute(vnode, attr) { function isFormAttribute(vnode3, attr) {
return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode.dom === activeElement() || vnode.tag === "option" && vnode.dom.parentNode === $doc.activeElement return attr === "value" || attr === "checked" || attr === "selectedIndex" || attr === "selected" && vnode3.dom === activeElement() || vnode3.tag === "option" && vnode3.dom.parentNode === $doc.activeElement
} }
function isLifecycleMethod(attr) { function isLifecycleMethod(attr) {
return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate" return attr === "oninit" || attr === "oncreate" || attr === "onupdate" || attr === "onremove" || attr === "onbeforeremove" || attr === "onbeforeupdate"
} }
function hasPropertyKey(vnode, key, ns) { function hasPropertyKey(vnode3, key, ns) {
// Filter out namespaced keys // Filter out namespaced keys
return ns === undefined && ( return ns === undefined && (
// If it's a custom element, just keep it. // If it's a custom element, just keep it.
vnode.tag.indexOf("-") > -1 || vnode.attrs != null && vnode.attrs.is || vnode3.tag.indexOf("-") > -1 || vnode3.attrs != null && vnode3.attrs.is ||
// If it's a normal element, let's try to avoid a few browser bugs. // If it's a normal element, let's try to avoid a few browser bugs.
key !== "href" && key !== "list" && key !== "form" && key !== "width" && key !== "height"// && key !== "type" key !== "href" && key !== "list" && key !== "form" && key !== "width" && key !== "height"// && key !== "type"
// Defer the property check until *after* we check everything. // Defer the property check until *after* we check everything.
) && key in vnode.dom ) && key in vnode3.dom
} }
//style //style
var uppercaseRegex = /[A-Z]/g var uppercaseRegex = /[A-Z]/g
@ -1221,45 +1260,45 @@ var coreRenderer = function($window) {
} }
} }
//event //event
function updateEvent(vnode, key, value) { function updateEvent(vnode3, key, value) {
if (vnode.events != null) { if (vnode3.events != null) {
if (vnode.events[key] === value) return if (vnode3.events[key] === value) return
if (value != null && (typeof value === "function" || typeof value === "object")) { if (value != null && (typeof value === "function" || typeof value === "object")) {
if (vnode.events[key] == null) vnode.dom.addEventListener(key.slice(2), vnode.events, false) if (vnode3.events[key] == null) vnode3.dom.addEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = value vnode3.events[key] = value
} else { } else {
if (vnode.events[key] != null) vnode.dom.removeEventListener(key.slice(2), vnode.events, false) if (vnode3.events[key] != null) vnode3.dom.removeEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = undefined vnode3.events[key] = undefined
} }
} else if (value != null && (typeof value === "function" || typeof value === "object")) { } else if (value != null && (typeof value === "function" || typeof value === "object")) {
vnode.events = new EventDict() vnode3.events = new EventDict()
vnode.dom.addEventListener(key.slice(2), vnode.events, false) vnode3.dom.addEventListener(key.slice(2), vnode3.events, false)
vnode.events[key] = value vnode3.events[key] = value
} }
} }
//lifecycle //lifecycle
function initLifecycle(source, vnode, hooks) { function initLifecycle(source, vnode3, hooks) {
if (typeof source.oninit === "function") callHook.call(source.oninit, vnode) if (typeof source.oninit === "function") callHook.call(source.oninit, vnode3)
if (typeof source.oncreate === "function") hooks.push(callHook.bind(source.oncreate, vnode)) if (typeof source.oncreate === "function") hooks.push(callHook.bind(source.oncreate, vnode3))
} }
function updateLifecycle(source, vnode, hooks) { function updateLifecycle(source, vnode3, hooks) {
if (typeof source.onupdate === "function") hooks.push(callHook.bind(source.onupdate, vnode)) if (typeof source.onupdate === "function") hooks.push(callHook.bind(source.onupdate, vnode3))
} }
function shouldNotUpdate(vnode, old) { function shouldNotUpdate(vnode3, old) {
do { do {
if (vnode.attrs != null && typeof vnode.attrs.onbeforeupdate === "function") { if (vnode3.attrs != null && typeof vnode3.attrs.onbeforeupdate === "function") {
var force = callHook.call(vnode.attrs.onbeforeupdate, vnode, old) var force = callHook.call(vnode3.attrs.onbeforeupdate, vnode3, old)
if (force !== undefined && !force) break if (force !== undefined && !force) break
} }
if (typeof vnode.tag !== "string" && typeof vnode.state.onbeforeupdate === "function") { if (typeof vnode3.tag !== "string" && typeof vnode3.state.onbeforeupdate === "function") {
var force = callHook.call(vnode.state.onbeforeupdate, vnode, old) var force = callHook.call(vnode3.state.onbeforeupdate, vnode3, old)
if (force !== undefined && !force) break if (force !== undefined && !force) break
} }
return false return false
} while (false); // eslint-disable-line no-constant-condition } while (false); // eslint-disable-line no-constant-condition
vnode.dom = old.dom vnode3.dom = old.dom
vnode.domSize = old.domSize vnode3.domSize = old.domSize
vnode.instance = old.instance vnode3.instance = old.instance
return true return true
} }
function render(dom, vnodes) { function render(dom, vnodes) {
@ -1289,7 +1328,7 @@ function throttle(callback) {
} }
} }
} }
var _12 = function($window, throttleMock) { var _15 = function($window, throttleMock) {
var renderService = coreRenderer($window) var renderService = coreRenderer($window)
var callbacks = [] var callbacks = []
var rendering = false var rendering = false
@ -1312,9 +1351,9 @@ var _12 = function($window, throttleMock) {
renderService.setRedraw(redraw) renderService.setRedraw(redraw)
return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render} return {subscribe: subscribe, unsubscribe: unsubscribe, redraw: redraw, render: renderService.render}
} }
var redrawService = _12(window) var redrawService = _15(window)
requestService.setCompletionCallback(redrawService.redraw) requestService.setCompletionCallback(redrawService.redraw)
var _17 = function(redrawService0) { var _20 = function(redrawService0) {
return function(root, component) { return function(root, component) {
if (component === null) { if (component === null) {
redrawService0.render(root, []) redrawService0.render(root, [])
@ -1331,7 +1370,7 @@ var _17 = function(redrawService0) {
run0() run0()
} }
} }
m.mount = _17(redrawService) m.mount = _20(redrawService)
var Promise = PromisePolyfill var Promise = PromisePolyfill
var parseQueryString = function(string) { var parseQueryString = function(string) {
if (string === "" || string == null) return {} if (string === "" || string == null) return {}
@ -1459,7 +1498,7 @@ var coreRouter = function($window) {
} }
return router return router
} }
var _21 = function($window, redrawService0) { var _24 = function($window, redrawService0) {
var routeService = coreRouter($window) var routeService = coreRouter($window)
var identity = function(v0) {return v0} var identity = function(v0) {return v0}
var render1, component, attrs3, currentPath, lastUpdate var render1, component, attrs3, currentPath, lastUpdate
@ -1506,9 +1545,9 @@ var _21 = function($window, redrawService0) {
} }
route.get = function() {return currentPath} route.get = function() {return currentPath}
route.prefix = function(prefix) {routeService.prefix = prefix} route.prefix = function(prefix) {routeService.prefix = prefix}
var link = function(options, vnode1) { var link = function(options, vnode5) {
vnode1.dom.setAttribute("href", routeService.prefix + vnode1.attrs.href) vnode5.dom.setAttribute("href", routeService.prefix + vnode5.attrs.href)
vnode1.dom.onclick = function(e) { vnode5.dom.onclick = function(e) {
if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return if (e.ctrlKey || e.metaKey || e.shiftKey || e.which === 2) return
e.preventDefault() e.preventDefault()
e.redraw = false e.redraw = false
@ -1527,9 +1566,9 @@ var _21 = function($window, redrawService0) {
} }
return route return route
} }
m.route = _21(window, redrawService) m.route = _24(window, redrawService)
var _28 = coreRenderer(window) var _31 = coreRenderer(window)
m.render = _28.render m.render = _31.render
m.redraw = redrawService.redraw m.redraw = redrawService.redraw
m.request = requestService.request m.request = requestService.request
m.jsonp = requestService.jsonp m.jsonp = requestService.jsonp