Bundled output for commit d00c34a721 [skip ci]
This commit is contained in:
parent
d00c34a721
commit
ed941a8f18
3 changed files with 16 additions and 16 deletions
|
|
@ -18,7 +18,7 @@ mithril.js [](https://ww
|
|||
|
||||
## What is Mithril?
|
||||
|
||||
A modern client-side Javascript framework for building Single Page Applications. It's small (<!-- size -->8.42 KB<!-- /size --> 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 (<!-- size -->8.43 KB<!-- /size --> gzipped), fast and provides routing and XHR utilities out of the box.
|
||||
|
||||
Mithril is used by companies like Vimeo and Nike, and open source platforms like Lichess 👍.
|
||||
|
||||
|
|
|
|||
|
|
@ -843,7 +843,7 @@ var coreRenderer = function($window) {
|
|||
if (key2[0] === "o" && key2[1] === "n") return updateEvent(vnode, key2, value)
|
||||
if ((old === value && !isFormAttribute(vnode, key2)) && typeof value !== "object" || value === undefined) return
|
||||
var element = vnode.dom
|
||||
if (key2.slice(0, 6) === "xlink:") element.setAttributeNS("http://www.w3.org/1999/xlink", key2.slice(6), value)
|
||||
if (key2.slice(0, 6) === "xlink:") element.setAttributeNS("http://www.w3.org/1999/xlink", key2, value)
|
||||
else if (key2 === "style") updateStyle(element, old, value)
|
||||
else if (key2 in element && !isAttribute(key2) && ns === undefined && !isCustomElement(vnode)) {
|
||||
if (key2 === "value") {
|
||||
|
|
|
|||
28
mithril.min.js
vendored
28
mithril.min.js
vendored
|
|
@ -28,18 +28,18 @@ y.normalize(e._state.view.call(e.state,e));if(e.instance===e)throw Error("A view
|
|||
t.createDocumentFragment();if(0<c){for(g=g.dom;--c;)a.appendChild(g.nextSibling);a.insertBefore(g,a.firstChild)}return a}return g.dom}function f(g,c,a){for(;c<g.length;c++)if(null!=g[c]&&null!=g[c].dom)return g[c].dom;return a}function n(g,c,a){a&&a.parentNode?g.insertBefore(c,a):g.appendChild(c)}function p(a){var c=a.children;if(null!=c&&1===c.length&&"<"===c[0].tag)c=c[0].children,a.dom.innerHTML!==c&&(a.dom.innerHTML=c);else if(null!=a.text||null!=c&&0!==c.length)throw Error("Child node of a contenteditable must be trusted");
|
||||
}function a(a,c,b,d){for(;c<b;c++){var g=a[c];null!=g&&(g.skip?g.skip=!1:v(g,d))}}function v(a,c){function b(){if(++d===g&&(u(a),a.dom)){var b=a.domSize||1;if(1<b)for(var e=a.dom;--b;){var f=e.nextSibling,k=f.parentNode;null!=k&&k.removeChild(f)}b=a.dom;e=b.parentNode;null!=e&&e.removeChild(b);if(b=null!=c&&null==a.domSize)b=a.attrs,b=!(null!=b&&(b.oncreate||b.onupdate||b.onbeforeremove||b.onremove));b&&"string"===typeof a.tag&&(c.pool?c.pool.push(a):c.pool=[a])}}var g=1,d=0;if(a.attrs&&"function"===
|
||||
typeof a.attrs.onbeforeremove){var f=a.attrs.onbeforeremove.call(a.state,a);null!=f&&"function"===typeof f.then&&(g++,f.then(b,b))}"string"!==typeof a.tag&&"function"===typeof a._state.onbeforeremove&&(f=a._state.onbeforeremove.call(a.state,a),null!=f&&"function"===typeof f.then&&(g++,f.then(b,b)));b()}function u(a){a.attrs&&"function"===typeof a.attrs.onremove&&a.attrs.onremove.call(a.state,a);if("string"!==typeof a.tag)"function"===typeof a._state.onremove&&a._state.onremove.call(a.state,a),null!=
|
||||
a.instance&&u(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&u(b)}}function D(a,c,b,d,f){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return A(a,c,d);if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===t.activeElement||"object"===typeof d)&&void 0!==d){var e=a.dom;if("xlink:"===c.slice(0,6))e.setAttributeNS("http://www.w3.org/1999/xlink",c.slice(6),d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===
|
||||
typeof a&&"object"===typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(e.style[g]=d[g]);for(g in a)g in d||(e.style[g]="")}else if(a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else for(g in"string"===typeof a&&(e.style.cssText=""),d)e.style[g]=d[g];else if(c in e&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&
|
||||
a.dom.value===g&&a.dom===t.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===t.activeElement)return}else if(null!==b&&a.dom.value===g&&a.dom===t.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===g)return}"input"===a.tag&&"type"===c?e.setAttribute(c,d):e[c]=d}else"boolean"===typeof d?d?e.setAttribute(c,""):e.removeAttribute(c):e.setAttribute("className"===c?"class":c,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===
|
||||
a||"onbeforeremove"===a||"onbeforeupdate"===a}function H(){}function A(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&
|
||||
a.oninit.call(c.state,c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function K(a,c,b){"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}var t=b.document,L=t.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},E;H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===
|
||||
typeof E&&E.call(a.target,a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=t.activeElement,f=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);m(a,a.vnodes,y.normalizeChildren(c),!1,b,null,"http://www.w3.org/1999/xhtml"===f?void 0:f);a.vnodes=c;for(f=0;f<b.length;f++)b[f]();null!=d&&t.activeElement!==d&&d.focus()},setEventCallback:function(a){return E=a}}},J=function(b,d){function h(b){b=
|
||||
m.indexOf(b);-1<b&&m.splice(b,2)}function k(){if(l)throw Error("Nested m.redraw.sync() call");l=!0;for(var b=1;b<m.length;b+=2)try{m[b]()}catch(n){"undefined"!==typeof console&&console.error(n)}l=!1}var q=Q(b);q.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:r()});var m=[],l=!1,r=(d||S)(k);r.sync=k;return{subscribe:function(b,d){h(b);m.push(b,d)},unsubscribe:h,redraw:r,render:q.render}}(window);M.setCompletionCallback(J.redraw);A.mount=function(b){return function(d,h){if(null===h)b.render(d,
|
||||
[]),b.unsubscribe(d);else{if(null==h.view&&"function"!==typeof h)throw Error("m.mount(element, component) expects a component, not a vnode");var k=function(){b.render(d,y(h))};b.subscribe(d,k);k()}}}(J);var V=w,N=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},h={},k=0;k<b.length;k++){var q=b[k].split("="),m=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var l=m.split(/\]\[?|\[/),r=d;-1<
|
||||
m.indexOf("[")&&l.pop();for(var f=0;f<l.length;f++){m=l[f];var n=l[f+1];n=""==n||!isNaN(parseInt(n,10));var p=f===l.length-1;""===m&&(m=l.slice(0,f).join(),null==h[m]&&(h[m]=0),m=h[m]++);null==r[m]&&(r[m]=p?q:n?[]:{});r=r[m]}}return d},W=function(b){function d(d){var f=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(b){return function(){null==l&&(l=m(function(){l=null;b()}))}}function k(b,d,k){var a=b.indexOf("?"),f=b.indexOf("#"),
|
||||
h=-1<a?a:-1<f?f:b.length;if(-1<a){a=N(b.slice(a+1,-1<f?f:b.length));for(var l in a)d[l]=a[l]}if(-1<f)for(l in d=N(b.slice(f+1)),d)k[l]=d[l];return b.slice(0,h)}var q="function"===typeof b.history.pushState,m="function"===typeof setImmediate?setImmediate:setTimeout,l,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return d("hash").slice(r.prefix.length);case "?":return d("search").slice(r.prefix.length)+d("hash");default:return d("pathname").slice(r.prefix.length)+d("search")+
|
||||
d("hash")}},setPath:function(d,l,h){var a={},f={};d=k(d,a,f);if(null!=l){for(var m in l)a[m]=l[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return l[d]})}(m=E(a))&&(d+="?"+m);(f=E(f))&&(d+="#"+f);q?(f=h?h.state:null,m=h?h.title:null,b.onpopstate(),h&&h.replace?b.history.replaceState(f,m,r.prefix+d):b.history.pushState(f,m,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,l,m){function a(){var a=r.getPath(),f={},h=k(a,f,f),p=b.history.state;if(null!=p)for(var n in p)f[n]=p[n];
|
||||
for(var q in d)if(p=new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(h)){h.replace(p,function(){for(var b=q.match(/:[^\/]+/g)||[],k=[].slice.call(arguments,1,-2),h=0;h<b.length;h++)f[b[h].replace(/:|\./g,"")]=decodeURIComponent(k[h]);l(d[q],f,a,q)});return}m(a,f)}q?b.onpopstate=h(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};A.route=function(b,d){var h=W(b),k=function(b){return b},q,m,l,r,f,n=function(b,a,n){function p(){null!=q&&d.render(b,
|
||||
q(y(m,l.key,l)))}if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var v=function(){p();v=d.redraw};d.subscribe(b,p);var w=function(b){if(b!==a)h.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};h.defineRoutes(n,function(a,b,d){var h=f=function(a,p){h===f&&(m=null==p||"function"!==typeof p.view&&"function"!==typeof p?"div":p,l=b,r=d,f=null,q=(a.render||k).bind(a),v())};a.view||"function"===typeof a?h({},a):a.onmatch?
|
||||
V.resolve(a.onmatch(b,d)).then(function(b){h(a,b)},w):h(a,"div")},w)};n.set=function(b,a,d){null!=f&&(d=d||{},d.replace=!0);f=null;h.setPath(b,a,d)};n.get=function(){return r};n.prefix=function(b){h.prefix=b};n.link=function(b){b.dom.setAttribute("href",h.prefix+b.attrs.href);b.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),n.set(a,void 0,void 0))}};n.param=function(b){return"undefined"!==
|
||||
a.instance&&u(a.instance);else if(a=a.children,Array.isArray(a))for(var c=0;c<a.length;c++){var b=a[c];null!=b&&u(b)}}function D(a,c,b,d,f){if("key"!==c&&"is"!==c&&!w(c)){if("o"===c[0]&&"n"===c[1])return A(a,c,d);if((b!==d||"value"===c||"checked"===c||"selectedIndex"===c||"selected"===c&&a.dom===t.activeElement||"object"===typeof d)&&void 0!==d){var e=a.dom;if("xlink:"===c.slice(0,6))e.setAttributeNS("http://www.w3.org/1999/xlink",c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&
|
||||
"object"===typeof d&&d!==a){for(var g in d)d[g]!==a[g]&&(e.style[g]=d[g]);for(g in a)g in d||(e.style[g]="")}else if(a===d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typeof d)e.style.cssText=d;else for(g in"string"===typeof a&&(e.style.cssText=""),d)e.style[g]=d[g];else if(c in e&&"href"!==c&&"list"!==c&&"form"!==c&&"width"!==c&&"height"!==c&&void 0===f&&!(a.attrs.is||-1<a.tag.indexOf("-"))){if("value"===c){g=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===
|
||||
g&&a.dom===t.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===t.activeElement)return}else if(null!==b&&a.dom.value===g&&a.dom===t.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===g)return}"input"===a.tag&&"type"===c?e.setAttribute(c,d):e[c]=d}else"boolean"===typeof d?d?e.setAttribute(c,""):e.removeAttribute(c):e.setAttribute("className"===c?"class":c,d)}}}function w(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===
|
||||
a||"onbeforeupdate"===a}function H(){}function A(a,c,b){null!=a.events?a.events[c]!==b&&(null==b||"function"!==typeof b&&"object"!==typeof b?(null!=a.events[c]&&a.dom.removeEventListener(c.slice(2),a.events,!1),a.events[c]=void 0):(null==a.events[c]&&a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)):null==b||"function"!==typeof b&&"object"!==typeof b||(a.events=new H,a.dom.addEventListener(c.slice(2),a.events,!1),a.events[c]=b)}function I(a,c,b){"function"===typeof a.oninit&&a.oninit.call(c.state,
|
||||
c);"function"===typeof a.oncreate&&b.push(a.oncreate.bind(c.state,c))}function K(a,c,b){"function"===typeof a.onupdate&&b.push(a.onupdate.bind(c.state,c))}var t=b.document,L=t.createDocumentFragment(),G={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},E;H.prototype=Object.create(null);H.prototype.handleEvent=function(a){var c=this["on"+a.type];"function"===typeof c?c.call(a.target,a):"function"===typeof c.handleEvent&&c.handleEvent(a);"function"===typeof E&&E.call(a.target,
|
||||
a)};return{render:function(a,c){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var b=[],d=t.activeElement,f=a.namespaceURI;null==a.vnodes&&(a.textContent="");Array.isArray(c)||(c=[c]);m(a,a.vnodes,y.normalizeChildren(c),!1,b,null,"http://www.w3.org/1999/xhtml"===f?void 0:f);a.vnodes=c;for(f=0;f<b.length;f++)b[f]();null!=d&&t.activeElement!==d&&d.focus()},setEventCallback:function(a){return E=a}}},J=function(b,d){function h(b){b=m.indexOf(b);
|
||||
-1<b&&m.splice(b,2)}function k(){if(l)throw Error("Nested m.redraw.sync() call");l=!0;for(var b=1;b<m.length;b+=2)try{m[b]()}catch(n){"undefined"!==typeof console&&console.error(n)}l=!1}var q=Q(b);q.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:r()});var m=[],l=!1,r=(d||S)(k);r.sync=k;return{subscribe:function(b,d){h(b);m.push(b,d)},unsubscribe:h,redraw:r,render:q.render}}(window);M.setCompletionCallback(J.redraw);A.mount=function(b){return function(d,h){if(null===h)b.render(d,[]),b.unsubscribe(d);
|
||||
else{if(null==h.view&&"function"!==typeof h)throw Error("m.mount(element, component) expects a component, not a vnode");var k=function(){b.render(d,y(h))};b.subscribe(d,k);k()}}}(J);var V=w,N=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));b=b.split("&");for(var d={},h={},k=0;k<b.length;k++){var q=b[k].split("="),m=decodeURIComponent(q[0]);q=2===q.length?decodeURIComponent(q[1]):"";"true"===q?q=!0:"false"===q&&(q=!1);var l=m.split(/\]\[?|\[/),r=d;-1<m.indexOf("[")&&l.pop();
|
||||
for(var f=0;f<l.length;f++){m=l[f];var n=l[f+1];n=""==n||!isNaN(parseInt(n,10));var p=f===l.length-1;""===m&&(m=l.slice(0,f).join(),null==h[m]&&(h[m]=0),m=h[m]++);null==r[m]&&(r[m]=p?q:n?[]:{});r=r[m]}}return d},W=function(b){function d(d){var f=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(b){return function(){null==l&&(l=m(function(){l=null;b()}))}}function k(b,d,k){var a=b.indexOf("?"),f=b.indexOf("#"),h=-1<a?a:-1<
|
||||
f?f:b.length;if(-1<a){a=N(b.slice(a+1,-1<f?f:b.length));for(var l in a)d[l]=a[l]}if(-1<f)for(l in d=N(b.slice(f+1)),d)k[l]=d[l];return b.slice(0,h)}var q="function"===typeof b.history.pushState,m="function"===typeof setImmediate?setImmediate:setTimeout,l,r={prefix:"#!",getPath:function(){switch(r.prefix.charAt(0)){case "#":return d("hash").slice(r.prefix.length);case "?":return d("search").slice(r.prefix.length)+d("hash");default:return d("pathname").slice(r.prefix.length)+d("search")+d("hash")}},
|
||||
setPath:function(d,l,h){var a={},f={};d=k(d,a,f);if(null!=l){for(var m in l)a[m]=l[m];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return l[d]})}(m=E(a))&&(d+="?"+m);(f=E(f))&&(d+="#"+f);q?(f=h?h.state:null,m=h?h.title:null,b.onpopstate(),h&&h.replace?b.history.replaceState(f,m,r.prefix+d):b.history.pushState(f,m,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,l,m){function a(){var a=r.getPath(),f={},h=k(a,f,f),p=b.history.state;if(null!=p)for(var n in p)f[n]=p[n];for(var q in d)if(p=
|
||||
new RegExp("^"+q.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(h)){h.replace(p,function(){for(var b=q.match(/:[^\/]+/g)||[],k=[].slice.call(arguments,1,-2),h=0;h<b.length;h++)f[b[h].replace(/:|\./g,"")]=decodeURIComponent(k[h]);l(d[q],f,a,q)});return}m(a,f)}q?b.onpopstate=h(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};A.route=function(b,d){var h=W(b),k=function(b){return b},q,m,l,r,f,n=function(b,a,n){function p(){null!=q&&d.render(b,q(y(m,l.key,
|
||||
l)))}if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var v=function(){p();v=d.redraw};d.subscribe(b,p);var w=function(b){if(b!==a)h.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};h.defineRoutes(n,function(a,b,d){var h=f=function(a,p){h===f&&(m=null==p||"function"!==typeof p.view&&"function"!==typeof p?"div":p,l=b,r=d,f=null,q=(a.render||k).bind(a),v())};a.view||"function"===typeof a?h({},a):a.onmatch?V.resolve(a.onmatch(b,
|
||||
d)).then(function(b){h(a,b)},w):h(a,"div")},w)};n.set=function(b,a,d){null!=f&&(d=d||{},d.replace=!0);f=null;h.setPath(b,a,d)};n.get=function(){return r};n.prefix=function(b){h.prefix=b};n.link=function(b){b.dom.setAttribute("href",h.prefix+b.attrs.href);b.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),n.set(a,void 0,void 0))}};n.param=function(b){return"undefined"!==
|
||||
typeof l&&"undefined"!==typeof b?l[b]:l};return n}(window,J);A.withAttr=function(b,d,h){return function(k){d.call(h||this,b in k.currentTarget?k.currentTarget[b]:k.currentTarget.getAttribute(b))}};var X=Q(window);A.render=X.render;A.redraw=J.redraw;A.request=M.request;A.jsonp=M.jsonp;A.parseQueryString=N;A.buildQueryString=E;A.version="1.1.3";A.vnode=y;"undefined"!==typeof module?module.exports=A:window.m=A})();
|
||||
Loading…
Add table
Add a link
Reference in a new issue