From 50c580b1e67f4d7863dba39a0e71d8b913d0be23 Mon Sep 17 00:00:00 2001 From: James Forbes Date: Thu, 31 Oct 2024 20:58:06 +1100 Subject: [PATCH] Release Artifacts for v2.2.9 [skip ci] --- README.md | 2 +- docs/recent-changes.md | 8 +++ mithril.js | 135 ++++++++++++++++++----------------------- mithril.min.js | 2 +- package-lock.json | 4 +- package.json | 2 +- 6 files changed, 73 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 32b8d20eb..f4bc9bee8 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ ## What is Mithril.js? -A modern client-side JavaScript framework for building Single Page Applications. It's small (9.12 KB gzipped), fast and provides routing and XHR utilities out of the box. +A modern client-side JavaScript framework for building Single Page Applications. It's small (9.05 KB gzipped), fast and provides routing and XHR utilities out of the box. Mithril.js is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍. diff --git a/docs/recent-changes.md b/docs/recent-changes.md index bda6e7a33..f66792f0e 100644 --- a/docs/recent-changes.md +++ b/docs/recent-changes.md @@ -1,4 +1,12 @@ +# Release v2.2.9 + +### Patch Changes + +#### [[refactor] Refactoring of hyperscript.js and render.js, including performance improvements (@kfule)](https://github.com/MithrilJS/mithril.js/pull/2983) + +Refactor hyperscript.js and render.js. In particular, the replacement of fix #2622 appears to have significantly improved the performance regression. + # Release v2.2.8 ### Patch Changes diff --git a/mithril.js b/mithril.js index 4fd695556..50e942d09 100644 --- a/mithril.js +++ b/mithril.js @@ -80,7 +80,7 @@ var hyperscriptVnode = function() { // This exists so I'm1 only saving it once. var hasOwn = {}.hasOwnProperty var selectorParser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[(.+?)(?:\s*=\s*("|'|)((?:\\["'\]]|.)*?)\5)?\])/g -var selectorCache = {} +var selectorCache = Object.create(null) function isEmpty(object) { for (var key in object) if (hasOwn.call(object, key)) return false return true @@ -100,6 +100,7 @@ function compileSelector(selector) { } } if (classes.length > 0) attrs.className = classes.join(" ") + if (isEmpty(attrs)) attrs = null return selectorCache[selector] = {tag: tag, attrs: attrs} } function execSelector(state, vnode) { @@ -107,27 +108,26 @@ function execSelector(state, vnode) { var hasClass = hasOwn.call(attrs, "class") var className = hasClass ? attrs.class : attrs.className vnode.tag = state.tag - if (!isEmpty(state.attrs)) { - var newAttrs = {} - for (var key in attrs) { - if (hasOwn.call(attrs, key)) newAttrs[key] = attrs[key] - } - attrs = newAttrs - } - for (var key in state.attrs) { - if (hasOwn.call(state.attrs, key) && key !== "className" && !hasOwn.call(attrs, key)){ - attrs[key] = state.attrs[key] - } - } - if (className != null || state.attrs.className != null) attrs.className = - className != null - ? state.attrs.className != null - ? String(state.attrs.className) + " " + String(className) - : className - : state.attrs.className != null - ? state.attrs.className - : null + if (state.attrs != null) { + attrs = Object.assign({}, state.attrs, attrs) + if (className != null || state.attrs.className != null) attrs.className = + className != null + ? state.attrs.className != null + ? String(state.attrs.className) + " " + String(className) + : className + : state.attrs.className != null + ? state.attrs.className + : null + } else { + if (className != null) attrs.className = className + } if (hasClass) attrs.class = null + // workaround for #2622 (reorder keys in attrs to set "type" first) + // The DOM does things to inputs based on the "type", so it needs set first. + // See: https://github.com/MithrilJS/mithril.js/issues/2622 + if (state.tag === "input" && hasOwn.call(attrs, "type")) { + attrs = Object.assign({type: attrs.type}, attrs) + } vnode.attrs = attrs return vnode } @@ -816,18 +816,12 @@ var _11 = function() { } //attrs2 function setAttrs(vnode3, attrs2, ns) { - // If you assign an input type0 that is not supported by IE 11 with an assignment expression, an error will occur. - // - // Also, the DOM does things to inputs based on the value, so it needs set first. - // See: https://github.com/MithrilJS/mithril.js/issues/2622 - if (vnode3.tag === "input" && attrs2.type != null) vnode3.dom.setAttribute("type", attrs2.type) - var isFileInput = attrs2 != null && vnode3.tag === "input" && attrs2.type === "file" for (var key in attrs2) { - setAttr(vnode3, key, null, attrs2[key], ns, isFileInput) + setAttr(vnode3, key, null, attrs2[key], ns) } } - function setAttr(vnode3, key, old, value, ns, isFileInput) { - if (key === "key" || key === "is" || value == null || isLifecycleMethod(key) || (old === value && !isFormAttribute(vnode3, key)) && typeof value !== "object" || key === "type" && vnode3.tag === "input") return + function setAttr(vnode3, key, old, value, ns) { + 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(vnode3, key, 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(vnode3.dom, old, value) @@ -835,6 +829,7 @@ var _11 = function() { if (key === "value") { // Only do the coercion if we're actually going to check the value. /* eslint-disable no-implicit-coercion */ + var isFileInput = vnode3.tag === "input" && vnode3.attrs.type === "file" //setting input[value] to same value by typing on focused element moves cursor to end in Chrome //setting input[type0=file][value] to same value causes an error to be generated if it's non-empty if ((vnode3.tag === "input" || vnode3.tag === "textarea") && vnode3.dom.value === "" + value && (isFileInput || vnode3.dom === activeElement(vnode3.dom))) return @@ -847,7 +842,9 @@ var _11 = function() { if (isFileInput && "" + value !== "") { console.error("`value` is read-only on file inputs!"); return } /* eslint-enable no-implicit-coercion */ } - vnode3.dom[key] = value + // If you assign an input type0 that is not supported by IE 11 with an assignment expression, an error will occur. + if (vnode3.tag === "input" && key === "type") vnode3.dom.setAttribute(key, value) + else vnode3.dom[key] = value } else { if (typeof value === "boolean") { if (value) vnode3.dom.setAttribute(key, "") @@ -895,14 +892,8 @@ var _11 = function() { console.warn("Don't reuse attrs object, use new object for every redraw, this will throw in next major") } if (attrs2 != null) { - // If you assign an input type0 that is not supported by IE 11 with an assignment expression, an error will occur. - // - // Also, the DOM does things to inputs based on the value, so it needs set first. - // See: https://github.com/MithrilJS/mithril.js/issues/2622 - if (vnode3.tag === "input" && attrs2.type != null) vnode3.dom.setAttribute("type", attrs2.type) - var isFileInput = vnode3.tag === "input" && attrs2.type === "file" for (var key in attrs2) { - setAttr(vnode3, key, old && old[key], attrs2[key], ns, isFileInput) + setAttr(vnode3, key, old && old[key], attrs2[key], ns) } } var val @@ -1142,12 +1133,6 @@ var buildQueryString = function(object) { else args.push(encodeURIComponent(key2) + (value1 != null && value1 !== "" ? "=" + encodeURIComponent(value1) : "")) } } -// This exists so I'm4 only saving it once. -var assign = Object.assign || function(target1, source) { - for (var key3 in source) { - if (hasOwn.call(source, key3)) target1[key3] = source[key3] - } -} // Returns `path` from `template` + `params` var buildPathname = function(template, params) { if ((/:([^\/\.-]+)(\.{3})?:/).test(template)) { @@ -1160,7 +1145,7 @@ var buildPathname = function(template, params) { var pathEnd = queryIndex < 0 ? queryEnd : queryIndex var path = template.slice(0, pathEnd) var query = {} - assign(query, params) + Object.assign(query, params) var resolved = path.replace(/:([^\/\.-]+)(\.{3})?/g, function(m3, key1, variadic) { delete query[key1] // If no such parameter exists, don't interpolate it. @@ -1364,7 +1349,7 @@ m.trust = hyperscript.trust m.fragment = hyperscript.fragment m.Fragment = "[" m.mount = mountRedraw.mount -var m5 = hyperscript +var m4 = hyperscript function decodeURIComponentSave0(str) { try { return decodeURIComponent(str) @@ -1378,22 +1363,22 @@ var parseQueryString = function(string) { var entries = string.split("&"), counters = {}, data0 = {} for (var i = 0; i < entries.length; i++) { var entry = entries[i].split("=") - var key5 = decodeURIComponentSave0(entry[0]) + var key4 = decodeURIComponentSave0(entry[0]) var value2 = entry.length === 2 ? decodeURIComponentSave0(entry[1]) : "" if (value2 === "true") value2 = true else if (value2 === "false") value2 = false - var levels = key5.split(/\]\[?|\[/) + var levels = key4.split(/\]\[?|\[/) var cursor = data0 - if (key5.indexOf("[") > -1) levels.pop() + if (key4.indexOf("[") > -1) levels.pop() for (var j0 = 0; j0 < levels.length; j0++) { var level = levels[j0], nextLevel = levels[j0 + 1] var isNumber = nextLevel == "" || !isNaN(parseInt(nextLevel, 10)) if (level === "") { - var key5 = levels.slice(0, j0).join() - if (counters[key5] == null) { - counters[key5] = Array.isArray(cursor) ? cursor.length : 0 + var key4 = levels.slice(0, j0).join() + if (counters[key4] == null) { + counters[key4] = Array.isArray(cursor) ? cursor.length : 0 } - level = counters[key5]++ + level = counters[key4]++ } // Disallow direct prototype pollution else if (level === "__proto__") break @@ -1443,9 +1428,9 @@ var compileTemplate = function(template) { // don't also accidentally escape `-` and make it harder to detect it to // ban it from template parameters. /:([^\/.-]+)(\.{3}|\.(?!\.)|-)?|[\\^$*+.()|\[\]{}]/g, - function(m6, key6, extra) { - if (key6 == null) return "\\" + m6 - keys.push({k: key6, r: extra === "..."}) + function(m5, key5, extra) { + if (key5 == null) return "\\" + m5 + keys.push({k: key5, r: extra === "..."}) if (extra === "...") return "(.*)" if (extra === ".") return "([^/]+)\\." return "([^/]+)" + (extra || "") @@ -1483,9 +1468,9 @@ var compileTemplate = function(template) { // "onbeforeremove", "onremove", // ] // var censor = (attrs4, extras) => { -// const result2 = Object.assign0(Object.create(null), attrs4) -// for (const key7 of magic) delete result2[key7] -// if (extras != null) for (const key7 of extras) delete result2[key7] +// const result2 = Object.assign(Object.create(null), attrs4) +// for (const key6 of magic) delete result2[key6] +// if (extras != null) for (const key6 of extras) delete result2[key6] // return result2 // } // ``` @@ -1494,15 +1479,15 @@ var magic = new RegExp("^(?:key|oninit|oncreate|onbeforeupdate|onupdate|onbefore var censor = function(attrs4, extras) { var result2 = {} if (extras != null) { - for (var key7 in attrs4) { - if (hasOwn.call(attrs4, key7) && !magic.test(key7) && extras.indexOf(key7) < 0) { - result2[key7] = attrs4[key7] + for (var key6 in attrs4) { + if (hasOwn.call(attrs4, key6) && !magic.test(key6) && extras.indexOf(key6) < 0) { + result2[key6] = attrs4[key6] } } } else { - for (var key7 in attrs4) { - if (hasOwn.call(attrs4, key7) && !magic.test(key7)) { - result2[key7] = attrs4[key7] + for (var key6 in attrs4) { + if (hasOwn.call(attrs4, key6) && !magic.test(key6)) { + result2[key6] = attrs4[key6] } } } @@ -1516,7 +1501,7 @@ function decodeURIComponentSave(component) { return component } } -var _28 = function($window, mountRedraw00) { +var _26 = function($window, mountRedraw00) { var callAsync = $window == null // In case Mithril.js' loaded globally without the DOM, let's not break ? null @@ -1541,7 +1526,7 @@ var _28 = function($window, mountRedraw00) { }, view: function() { if (!state || sentinel0 === currentResolver) return - // Wrap in a fragment0 to preserve existing key4 semantics + // Wrap in a fragment0 to preserve existing key3 semantics var vnode6 = [Vnode(component, attrs3.key, attrs3)] if (currentResolver) vnode6 = currentResolver.render(vnode6[0]) return vnode6 @@ -1567,7 +1552,7 @@ var _28 = function($window, mountRedraw00) { .replace(/(?:%[a-f89][a-f0-9])+/gim, decodeURIComponentSave) .slice(route.prefix.length) var data = parsePathname(path0) - assign(data.params, $window.history.state) + Object.assign(data.params, $window.history.state) function reject(e) { console.error(e) setPath(fallbackRoute, null, {replace: true}) @@ -1615,7 +1600,7 @@ var _28 = function($window, mountRedraw00) { setPath(fallbackRoute, null, {replace: true}) } } - // Set it unconditionally so `m5.route.set` and `m5.route.Link` both work, + // Set it unconditionally so `m4.route.set` and `m4.route.Link` both work, // even if neither `pushState` nor `hashchange` are supported. It's // cleared if `hashchange` is2 used, since that makes it automatically // async. @@ -1687,7 +1672,7 @@ var _28 = function($window, mountRedraw00) { // // We don't strip the other parameters because for convenience we // let them be specified in the selector as well. - var child0 = m5( + var child0 = m4( vnode6.attrs.selector || "a", censor(vnode6.attrs, ["options", "params", "selector", "onclick"]), vnode6.children @@ -1727,13 +1712,13 @@ var _28 = function($window, mountRedraw00) { // would expect. There's a lot more valid ways to click a // link than this, and one might want to not simply click a // link, but right click or command-click it to copy the - // link target2, etc. Nope, this isn't just for blind people. + // link target1, etc. Nope, this isn't just for blind people. if ( // Skip if `onclick` prevented default result1 !== false && !e.defaultPrevented && // Ignore everything but left clicks (e.button === 0 || e.which === 0 || e.which === 1) && - // Let the browser handle `target2=_blank`, etc. + // Let the browser handle `target1=_blank`, etc. (!e.currentTarget.target || e.currentTarget.target === "_self") && // No modifier keys !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey @@ -1747,12 +1732,12 @@ var _28 = function($window, mountRedraw00) { return child0 }, } - route.param = function(key4) { - return attrs3 && key4 != null ? attrs3[key4] : attrs3 + route.param = function(key3) { + return attrs3 && key3 != null ? attrs3[key3] : attrs3 } return route } -m.route = _28(typeof window !== "undefined" ? window : null, mountRedraw) +m.route = _26(typeof window !== "undefined" ? window : null, mountRedraw) m.render = render m.redraw = mountRedraw.redraw m.request = request.request diff --git a/mithril.min.js b/mithril.min.js index 80a0e3747..bf762f12e 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1 +1 @@ -!function(){"use strict";function e(e,t,n,r,o,l){return{tag:e,key:t,attrs:n,children:r,text:o,dom:l,domSize:void 0,state:void 0,events:void 0,instance:void 0}}e.normalize=function(t){return Array.isArray(t)?e("[",void 0,void 0,e.normalizeChildren(t),void 0,void 0):null==t||"boolean"==typeof t?null:"object"==typeof t?t:e("#",void 0,void 0,String(t),void 0,void 0)},e.normalizeChildren=function(t){var n=[];if(t.length){for(var r=null!=t[0]&&null!=t[0].key,o=1;o0&&(i.className=l.join(" ")),o[e]={tag:n,attrs:i}}function i(e,t){var r=t.attrs,o=n.call(r,"class"),l=o?r.class:r.className;if(t.tag=e.tag,!function(e){for(var t in e)if(n.call(e,t))return!1;return!0}(e.attrs)){var i={};for(var a in r)n.call(r,a)&&(i[a]=r[a]);r=i}for(var a in e.attrs)n.call(e.attrs,a)&&"className"!==a&&!n.call(r,a)&&(r[a]=e.attrs[a]);return null==l&&null==e.attrs.className||(r.className=null!=l?null!=e.attrs.className?String(e.attrs.className)+" "+String(l):l:null!=e.attrs.className?e.attrs.className:null),o&&(r.class=null),t.attrs=r,t}function a(n){if(null==n||"string"!=typeof n&&"function"!=typeof n&&"function"!=typeof n.view)throw Error("The selector must be either a string or a component.");var r=t.apply(1,arguments);return"string"==typeof n&&(r.children=e.normalizeChildren(r.children),"["!==n)?i(o[n]||l(n),r):(r.tag=n,r)}a.trust=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)},a.fragment=function(){var n=t.apply(0,arguments);return n.tag="[",n.children=e.normalizeChildren(n.children),n};var u=new WeakMap;var s={delayedRemoval:u,domFor:function*(e,t={}){var n=e.dom,r=e.domSize,o=t.generation;if(null!=n)do{var l=n.nextSibling;u.get(n)===o&&(yield n,r--),n=l}while(r)}},f=s.delayedRemoval,c=s.domFor,d=function(){var t,n,r={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function o(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||r[e.tag]}function i(e,t){if(e.state!==t)throw new Error("'vnode.state' must not be modified.")}function a(e){var t=e.state;try{return this.apply(t,arguments)}finally{i(e,t)}}function u(e){try{return o(e).activeElement}catch(e){return null}}function s(e,t,n,r,o,l,i){for(var a=n;a'+t.children+"",i=i.firstChild):i.innerHTML=t.children,t.dom=i.firstChild,t.domSize=i.childNodes.length;for(var a,u=o(e).createDocumentFragment();a=i.firstChild;)u.appendChild(a);x(e,u,r)}function v(e,t,n,r,o,l){if(t!==n&&(null!=t||null!=n))if(null==t||0===t.length)s(e,n,0,n.length,r,o,l);else if(null==n||0===n.length)S(e,t,0,t.length);else{var i=null!=t[0]&&null!=t[0].key,a=null!=n[0]&&null!=n[0].key,u=0,f=0;if(!i)for(;f=f&&z>=u&&(m=t[k],v=n[z],m.key===v.key);)m!==v&&h(e,m,v,r,o,l),null!=v.dom&&(o=v.dom),k--,z--;for(;k>=f&&z>=u&&(c=t[f],p=n[u],c.key===p.key);)f++,u++,c!==p&&h(e,c,p,r,w(t,f,o),l);for(;k>=f&&z>=u&&u!==z&&c.key===v.key&&m.key===p.key;)b(e,m,x=w(t,f,o)),m!==p&&h(e,m,p,r,x,l),++u<=--z&&b(e,c,o),c!==v&&h(e,c,v,r,o,l),null!=v.dom&&(o=v.dom),f++,m=t[--k],v=n[z],c=t[f],p=n[u];for(;k>=f&&z>=u&&m.key===v.key;)m!==v&&h(e,m,v,r,o,l),null!=v.dom&&(o=v.dom),z--,m=t[--k],v=n[z];if(u>z)S(e,t,f,k+1);else if(f>k)s(e,n,u,z+1,r,o,l);else{var j,A,C=o,O=z-u+1,T=new Array(O),N=0,$=0,L=2147483647,R=0;for($=0;$=u;$--){null==j&&(j=y(t,f,k+1));var I=j[(v=n[$]).key];null!=I&&(L=I>>1)+(r>>>1)+(n&r&1);e[t[a]]0&&(g[o]=t[n-1]),t[n]=o)}}n=t.length,r=t[n-1];for(;n-- >0;)t[n]=r,r=g[r];return g.length=0,t}(T)).length-1,$=z;$>=u;$--)p=n[$],-1===T[$-u]?d(e,p,r,l,o):A[N]===$-u?N--:b(e,p,o),null!=p.dom&&(o=n[$].dom);else for($=z;$>=u;$--)p=n[$],-1===T[$-u]&&d(e,p,r,l,o),null!=p.dom&&(o=n[$].dom)}}else{var P=t.lengthP&&S(e,t,u,t.length),n.length>P&&s(e,n,u,n.length,r,o,l)}}}function h(t,n,r,o,i,u){var s=n.tag;if(s===r.tag){if(r.state=n.state,r.events=n.events,function(e,t){do{var n;if(null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate)if(void 0!==(n=a.call(e.attrs.onbeforeupdate,e,t))&&!n)break;if("string"!=typeof e.tag&&"function"==typeof e.state.onbeforeupdate)if(void 0!==(n=a.call(e.state.onbeforeupdate,e,t))&&!n)break;return!1}while(0);return e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,e.attrs=t.attrs,e.children=t.children,e.text=t.text,!0}(r,n))return;if("string"==typeof s)switch(null!=r.attrs&&_(r.attrs,r,o),s){case"#":!function(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children);t.dom=e.dom}(n,r);break;case"<":!function(e,t,n,r,o){t.children!==n.children?(z(e,t,void 0),m(e,n,r,o)):(n.dom=t.dom,n.domSize=t.domSize)}(t,n,r,u,i);break;case"[":!function(e,t,n,r,o,l){v(e,t.children,n.children,r,o,l);var i=0,a=n.children;if(n.dom=null,null!=a){for(var u=0;u-1||null!=e.attrs&&e.attrs.is||"href"!==t&&"list"!==t&&"form"!==t&&"width"!==t&&"height"!==t)&&t in e.dom}var N,$=/[A-Z]/g;function L(e){return"-"+e.toLowerCase()}function R(e){return"-"===e[0]&&"-"===e[1]?e:"cssFloat"===e?"float":e.replace($,L)}function I(e,t,n){if(t===n);else if(null==n)e.style="";else if("object"!=typeof n)e.style=n;else if(null==t||"object"!=typeof t)for(var r in e.style.cssText="",n){null!=(o=n[r])&&e.style.setProperty(R(r),String(o))}else{for(var r in n){var o;null!=(o=n[r])&&(o=String(o))!==String(t[r])&&e.style.setProperty(R(r),o)}for(var r in t)null!=t[r]&&null==n[r]&&e.style.removeProperty(R(r))}}function P(){this._=t}function D(e,n,r){if(null!=e.events){if(e.events._=t,e.events[n]===r)return;null==r||"function"!=typeof r&&"object"!=typeof r?(null!=e.events[n]&&e.dom.removeEventListener(n.slice(2),e.events,!1),e.events[n]=void 0):(null==e.events[n]&&e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}else null==r||"function"!=typeof r&&"object"!=typeof r||(e.events=new P,e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}function F(e,t,n){"function"==typeof e.oninit&&a.call(e.oninit,t),"function"==typeof e.oncreate&&n.push(a.bind(e.oncreate,t))}function _(e,t,n){"function"==typeof e.onupdate&&n.push(a.bind(e.onupdate,t))}return P.prototype=Object.create(null),P.prototype.handleEvent=function(e){var t,n=this["on"+e.type];"function"==typeof n?t=n.call(e.currentTarget,e):"function"==typeof n.handleEvent&&n.handleEvent(e),this._&&!1!==e.redraw&&(0,this._)(),!1===t&&(e.preventDefault(),e.stopPropagation())},function(r,o,l){if(!r)throw new TypeError("DOM element being rendered to does not exist.");if(null!=N&&r.contains(N))throw new TypeError("Node is currently being rendered to and thus is locked.");var i=t,a=N,s=[],f=u(r),c=r.namespaceURI;N=r,t="function"==typeof l?l:void 0,n={};try{null==r.vnodes&&(r.textContent=""),o=e.normalizeChildren(Array.isArray(o)?o:[o]),v(r,r.vnodes,o,s,null,"http://www.w3.org/1999/xhtml"===c?void 0:c),r.vnodes=o,null!=f&&u(r)!==f&&"function"==typeof f.focus&&f.focus();for(var d=0;d=0&&(o.splice(l,2),l<=i&&(i-=2),t(n,[])),null!=r&&(o.push(n,r),t(n,e(r),u))},redraw:u}}(d,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),m=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return"";var t=[];for(var n in e)r(n,e[n]);return t.join("&");function r(e,n){if(Array.isArray(n))for(var o=0;o=0&&(p+=e.slice(n,o)),s>=0&&(p+=(n<0?"?":"&")+u.slice(s,c));var h=m(a);return h&&(p+=(n<0&&s<0?"?":"&")+h),r>=0&&(p+=e.slice(r)),f>=0&&(p+=(r<0?"":"&")+u.slice(f)),p},y=function(e,t){function r(e){return new Promise(e)}function o(e,t){for(var r in e.headers)if(n.call(e.headers,r)&&r.toLowerCase()===t)return!0;return!1}return r.prototype=Promise.prototype,r.__proto__=Promise,{request:function(l,i){"string"!=typeof l?(i=l,l=l.url):null==i&&(i={});var a=function(t,r){return new Promise((function(l,i){t=h(t,r.params);var a,u=null!=r.method?r.method.toUpperCase():"GET",s=r.body,f=(null==r.serialize||r.serialize===JSON.serialize)&&!(s instanceof e.FormData||s instanceof e.URLSearchParams),c=r.responseType||("function"==typeof r.extract?"":"json"),d=new e.XMLHttpRequest,p=!1,m=!1,v=d,y=d.abort;for(var g in d.abort=function(){p=!0,y.call(this)},d.open(u,t,!1!==r.async,"string"==typeof r.user?r.user:void 0,"string"==typeof r.password?r.password:void 0),f&&null!=s&&!o(r,"content-type")&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof r.deserialize||o(r,"accept")||d.setRequestHeader("Accept","application/json, text/*"),r.withCredentials&&(d.withCredentials=r.withCredentials),r.timeout&&(d.timeout=r.timeout),d.responseType=c,r.headers)n.call(r.headers,g)&&d.setRequestHeader(g,r.headers[g]);d.onreadystatechange=function(e){if(!p&&4===e.target.readyState)try{var n,o=e.target.status>=200&&e.target.status<300||304===e.target.status||/^file:\/\//i.test(t),a=e.target.response;if("json"===c){if(!e.target.responseType&&"function"!=typeof r.extract)try{a=JSON.parse(e.target.responseText)}catch(e){a=null}}else c&&"text"!==c||null==a&&(a=e.target.responseText);if("function"==typeof r.extract?(a=r.extract(e.target,r),o=!0):"function"==typeof r.deserialize&&(a=r.deserialize(a)),o){if("function"==typeof r.type)if(Array.isArray(a))for(var u=0;u-1&&u.pop();for(var f=0;f0&&(a.className=i.join(" ")),function(e){for(var t in e)if(n.call(e,t))return!1;return!0}(a)&&(a=null),o[e]={tag:l,attrs:a}}function i(e,t){var r=t.attrs,o=n.call(r,"class"),l=o?r.class:r.className;return t.tag=e.tag,null!=e.attrs?(r=Object.assign({},e.attrs,r),null==l&&null==e.attrs.className||(r.className=null!=l?null!=e.attrs.className?String(e.attrs.className)+" "+String(l):l:null!=e.attrs.className?e.attrs.className:null)):null!=l&&(r.className=l),o&&(r.class=null),"input"===e.tag&&n.call(r,"type")&&(r=Object.assign({type:r.type},r)),t.attrs=r,t}function a(n){if(null==n||"string"!=typeof n&&"function"!=typeof n&&"function"!=typeof n.view)throw Error("The selector must be either a string or a component.");var r=t.apply(1,arguments);return"string"==typeof n&&(r.children=e.normalizeChildren(r.children),"["!==n)?i(o[n]||l(n),r):(r.tag=n,r)}a.trust=function(t){return null==t&&(t=""),e("<",void 0,void 0,t,void 0,void 0)},a.fragment=function(){var n=t.apply(0,arguments);return n.tag="[",n.children=e.normalizeChildren(n.children),n};var u=new WeakMap;var s={delayedRemoval:u,domFor:function*(e,t={}){var n=e.dom,r=e.domSize,o=t.generation;if(null!=n)do{var l=n.nextSibling;u.get(n)===o&&(yield n,r--),n=l}while(r)}},f=s.delayedRemoval,c=s.domFor,d=function(){var t,n,r={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"};function o(e){return e.ownerDocument}function l(e){return e.attrs&&e.attrs.xmlns||r[e.tag]}function i(e,t){if(e.state!==t)throw new Error("'vnode.state' must not be modified.")}function a(e){var t=e.state;try{return this.apply(t,arguments)}finally{i(e,t)}}function u(e){try{return o(e).activeElement}catch(e){return null}}function s(e,t,n,r,o,l,i){for(var a=n;a'+t.children+"",i=i.firstChild):i.innerHTML=t.children,t.dom=i.firstChild,t.domSize=i.childNodes.length;for(var a,u=o(e).createDocumentFragment();a=i.firstChild;)u.appendChild(a);x(e,u,r)}function v(e,t,n,r,o,l){if(t!==n&&(null!=t||null!=n))if(null==t||0===t.length)s(e,n,0,n.length,r,o,l);else if(null==n||0===n.length)S(e,t,0,t.length);else{var i=null!=t[0]&&null!=t[0].key,a=null!=n[0]&&null!=n[0].key,u=0,f=0;if(!i)for(;f=f&&z>=u&&(m=t[k],v=n[z],m.key===v.key);)m!==v&&h(e,m,v,r,o,l),null!=v.dom&&(o=v.dom),k--,z--;for(;k>=f&&z>=u&&(c=t[f],p=n[u],c.key===p.key);)f++,u++,c!==p&&h(e,c,p,r,w(t,f,o),l);for(;k>=f&&z>=u&&u!==z&&c.key===v.key&&m.key===p.key;)b(e,m,x=w(t,f,o)),m!==p&&h(e,m,p,r,x,l),++u<=--z&&b(e,c,o),c!==v&&h(e,c,v,r,o,l),null!=v.dom&&(o=v.dom),f++,m=t[--k],v=n[z],c=t[f],p=n[u];for(;k>=f&&z>=u&&m.key===v.key;)m!==v&&h(e,m,v,r,o,l),null!=v.dom&&(o=v.dom),z--,m=t[--k],v=n[z];if(u>z)S(e,t,f,k+1);else if(f>k)s(e,n,u,z+1,r,o,l);else{var j,O,A=o,C=z-u+1,T=new Array(C),N=0,$=0,L=2147483647,R=0;for($=0;$=u;$--){null==j&&(j=y(t,f,k+1));var I=j[(v=n[$]).key];null!=I&&(L=I>>1)+(r>>>1)+(n&r&1);e[t[a]]0&&(g[o]=t[n-1]),t[n]=o)}}n=t.length,r=t[n-1];for(;n-- >0;)t[n]=r,r=g[r];return g.length=0,t}(T)).length-1,$=z;$>=u;$--)p=n[$],-1===T[$-u]?d(e,p,r,l,o):O[N]===$-u?N--:b(e,p,o),null!=p.dom&&(o=n[$].dom);else for($=z;$>=u;$--)p=n[$],-1===T[$-u]&&d(e,p,r,l,o),null!=p.dom&&(o=n[$].dom)}}else{var P=t.lengthP&&S(e,t,u,t.length),n.length>P&&s(e,n,u,n.length,r,o,l)}}}function h(t,n,r,o,i,u){var s=n.tag;if(s===r.tag){if(r.state=n.state,r.events=n.events,function(e,t){do{var n;if(null!=e.attrs&&"function"==typeof e.attrs.onbeforeupdate)if(void 0!==(n=a.call(e.attrs.onbeforeupdate,e,t))&&!n)break;if("string"!=typeof e.tag&&"function"==typeof e.state.onbeforeupdate)if(void 0!==(n=a.call(e.state.onbeforeupdate,e,t))&&!n)break;return!1}while(0);return e.dom=t.dom,e.domSize=t.domSize,e.instance=t.instance,e.attrs=t.attrs,e.children=t.children,e.text=t.text,!0}(r,n))return;if("string"==typeof s)switch(null!=r.attrs&&_(r.attrs,r,o),s){case"#":!function(e,t){e.children.toString()!==t.children.toString()&&(e.dom.nodeValue=t.children);t.dom=e.dom}(n,r);break;case"<":!function(e,t,n,r,o){t.children!==n.children?(z(e,t,void 0),m(e,n,r,o)):(n.dom=t.dom,n.domSize=t.domSize)}(t,n,r,u,i);break;case"[":!function(e,t,n,r,o,l){v(e,t.children,n.children,r,o,l);var i=0,a=n.children;if(n.dom=null,null!=a){for(var u=0;u-1||null!=e.attrs&&e.attrs.is||"href"!==t&&"list"!==t&&"form"!==t&&"width"!==t&&"height"!==t)&&t in e.dom}var N,$=/[A-Z]/g;function L(e){return"-"+e.toLowerCase()}function R(e){return"-"===e[0]&&"-"===e[1]?e:"cssFloat"===e?"float":e.replace($,L)}function I(e,t,n){if(t===n);else if(null==n)e.style="";else if("object"!=typeof n)e.style=n;else if(null==t||"object"!=typeof t)for(var r in e.style.cssText="",n){null!=(o=n[r])&&e.style.setProperty(R(r),String(o))}else{for(var r in n){var o;null!=(o=n[r])&&(o=String(o))!==String(t[r])&&e.style.setProperty(R(r),o)}for(var r in t)null!=t[r]&&null==n[r]&&e.style.removeProperty(R(r))}}function P(){this._=t}function D(e,n,r){if(null!=e.events){if(e.events._=t,e.events[n]===r)return;null==r||"function"!=typeof r&&"object"!=typeof r?(null!=e.events[n]&&e.dom.removeEventListener(n.slice(2),e.events,!1),e.events[n]=void 0):(null==e.events[n]&&e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}else null==r||"function"!=typeof r&&"object"!=typeof r||(e.events=new P,e.dom.addEventListener(n.slice(2),e.events,!1),e.events[n]=r)}function F(e,t,n){"function"==typeof e.oninit&&a.call(e.oninit,t),"function"==typeof e.oncreate&&n.push(a.bind(e.oncreate,t))}function _(e,t,n){"function"==typeof e.onupdate&&n.push(a.bind(e.onupdate,t))}return P.prototype=Object.create(null),P.prototype.handleEvent=function(e){var t,n=this["on"+e.type];"function"==typeof n?t=n.call(e.currentTarget,e):"function"==typeof n.handleEvent&&n.handleEvent(e),this._&&!1!==e.redraw&&(0,this._)(),!1===t&&(e.preventDefault(),e.stopPropagation())},function(r,o,l){if(!r)throw new TypeError("DOM element being rendered to does not exist.");if(null!=N&&r.contains(N))throw new TypeError("Node is currently being rendered to and thus is locked.");var i=t,a=N,s=[],f=u(r),c=r.namespaceURI;N=r,t="function"==typeof l?l:void 0,n={};try{null==r.vnodes&&(r.textContent=""),o=e.normalizeChildren(Array.isArray(o)?o:[o]),v(r,r.vnodes,o,s,null,"http://www.w3.org/1999/xhtml"===c?void 0:c),r.vnodes=o,null!=f&&u(r)!==f&&"function"==typeof f.focus&&f.focus();for(var d=0;d=0&&(o.splice(l,2),l<=i&&(i-=2),t(n,[])),null!=r&&(o.push(n,r),t(n,e(r),u))},redraw:u}}(d,"undefined"!=typeof requestAnimationFrame?requestAnimationFrame:null,"undefined"!=typeof console?console:null),m=function(e){if("[object Object]"!==Object.prototype.toString.call(e))return"";var t=[];for(var n in e)r(n,e[n]);return t.join("&");function r(e,n){if(Array.isArray(n))for(var o=0;o=0&&(p+=e.slice(n,o)),s>=0&&(p+=(n<0?"?":"&")+u.slice(s,c));var v=m(a);return v&&(p+=(n<0&&s<0?"?":"&")+v),r>=0&&(p+=e.slice(r)),f>=0&&(p+=(r<0?"":"&")+u.slice(f)),p},h=function(e,t){function r(e){return new Promise(e)}function o(e,t){for(var r in e.headers)if(n.call(e.headers,r)&&r.toLowerCase()===t)return!0;return!1}return r.prototype=Promise.prototype,r.__proto__=Promise,{request:function(l,i){"string"!=typeof l?(i=l,l=l.url):null==i&&(i={});var a=function(t,r){return new Promise((function(l,i){t=v(t,r.params);var a,u=null!=r.method?r.method.toUpperCase():"GET",s=r.body,f=(null==r.serialize||r.serialize===JSON.serialize)&&!(s instanceof e.FormData||s instanceof e.URLSearchParams),c=r.responseType||("function"==typeof r.extract?"":"json"),d=new e.XMLHttpRequest,p=!1,m=!1,h=d,y=d.abort;for(var g in d.abort=function(){p=!0,y.call(this)},d.open(u,t,!1!==r.async,"string"==typeof r.user?r.user:void 0,"string"==typeof r.password?r.password:void 0),f&&null!=s&&!o(r,"content-type")&&d.setRequestHeader("Content-Type","application/json; charset=utf-8"),"function"==typeof r.deserialize||o(r,"accept")||d.setRequestHeader("Accept","application/json, text/*"),r.withCredentials&&(d.withCredentials=r.withCredentials),r.timeout&&(d.timeout=r.timeout),d.responseType=c,r.headers)n.call(r.headers,g)&&d.setRequestHeader(g,r.headers[g]);d.onreadystatechange=function(e){if(!p&&4===e.target.readyState)try{var n,o=e.target.status>=200&&e.target.status<300||304===e.target.status||/^file:\/\//i.test(t),a=e.target.response;if("json"===c){if(!e.target.responseType&&"function"!=typeof r.extract)try{a=JSON.parse(e.target.responseText)}catch(e){a=null}}else c&&"text"!==c||null==a&&(a=e.target.responseText);if("function"==typeof r.extract?(a=r.extract(e.target,r),o=!0):"function"==typeof r.deserialize&&(a=r.deserialize(a)),o){if("function"==typeof r.type)if(Array.isArray(a))for(var u=0;u-1&&u.pop();for(var f=0;f