Bundled output for commit 11183f339d [skip ci]
This commit is contained in:
parent
11183f339d
commit
67e1aad944
3 changed files with 13 additions and 12 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.33 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.32 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 👍.
|
||||
|
||||
|
|
|
|||
|
|
@ -991,7 +991,8 @@ var coreRenderer = function($window) {
|
|||
updateNodes(dom, dom.vnodes, Vnode.normalizeChildren(vnodes), false, hooks, null, namespace === "http://www.w3.org/1999/xhtml" ? undefined : namespace)
|
||||
dom.vnodes = vnodes
|
||||
for (var i = 0; i < hooks.length; i++) hooks[i]()
|
||||
if ($doc.activeElement !== active) active.focus()
|
||||
// document.activeElement can return null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/activeElement
|
||||
if (active != null && $doc.activeElement !== active) active.focus()
|
||||
}
|
||||
return {render: render, setEventCallback: setEventCallback}
|
||||
}
|
||||
|
|
|
|||
20
mithril.min.js
vendored
20
mithril.min.js
vendored
|
|
@ -33,13 +33,13 @@ c,d);else if("style"===c)if(a=b,null!=a&&null!=d&&"object"===typeof a&&"object"=
|
|||
c){f=""+d;if(("input"===a.tag||"textarea"===a.tag)&&a.dom.value===f&&a.dom===x.activeElement)return;if("select"===a.tag)if(null===d){if(-1===a.dom.selectedIndex&&a.dom===x.activeElement)return}else if(null!==b&&a.dom.value===f&&a.dom===x.activeElement)return;if("option"===a.tag&&null!=b&&a.dom.value===f)return}"input"===a.tag&&"type"===c?h.setAttribute(c,d):h[c]=d}else"boolean"===typeof d?d?h.setAttribute(c,""):h.removeAttribute(c):h.setAttribute("className"===c?"class":c,d)}}function w(a){return"oninit"===
|
||||
a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function G(a,b,d){var c=a.dom,e="function"!==typeof C?d:function(a){var b=d.call(c,a);C.call(c,a);return b};if(b in c)c[b]="function"===typeof d?e:null;else{var h=b.slice(2);void 0===a.events&&(a.events={});a.events[b]!==e&&(null!=a.events[b]&&c.removeEventListener(h,a.events[b],!1),"function"===typeof d&&(a.events[b]=e,c.addEventListener(h,a.events[b],!1)))}}function A(a,b,d){"function"===typeof a.oninit&&
|
||||
a.oninit.call(b.state,b);"function"===typeof a.oncreate&&d.push(a.oncreate.bind(b.state,b))}function J(a,b,d){"function"===typeof a.onupdate&&d.push(a.onupdate.bind(b.state,b))}var x=b.document,K=x.createDocumentFragment(),P={svg:"http://www.w3.org/2000/svg",math:"http://www.w3.org/1998/Math/MathML"},C;return{render:function(a,b){if(!a)throw Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var c=[],d=x.activeElement,e=a.namespaceURI;null==a.vnodes&&(a.textContent=
|
||||
"");Array.isArray(b)||(b=[b]);f(a,a.vnodes,y.normalizeChildren(b),!1,c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;for(e=0;e<c.length;e++)c[e]();x.activeElement!==d&&d.focus()},setEventCallback:function(a){return C=a}}},I=function(b,d){function e(b){b=f.indexOf(b);-1<b&&f.splice(b,2)}function k(){if(g)throw Error("Nested m.redraw.sync() call");g=!0;for(var b=1;b<f.length;b+=2)try{f[b]()}catch(m){}g=!1}var n=Q(b);n.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:r()});var f=
|
||||
[],g=!1,r=(d||S)(k);r.sync=k;return{subscribe:function(b,d){e(b);f.push(b,d)},unsubscribe:e,redraw:r,render:n.render}}(window);L.setCompletionCallback(I.redraw);A.mount=function(b){return function(d,e){if(null===e)b.render(d,[]),b.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var k=function(){b.render(d,y(e))};b.subscribe(d,k);k()}}}(I);var U=w,M=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&(b=b.slice(1));
|
||||
b=b.split("&");for(var d={},e={},k=0;k<b.length;k++){var n=b[k].split("=");var f=decodeURIComponent(n[0]);n=2===n.length?decodeURIComponent(n[1]):"";"true"===n?n=!0:"false"===n&&(n=!1);var g=f.split(/\]\[?|\[/),r=d;-1<f.indexOf("[")&&g.pop();for(var l=0;l<g.length;l++){f=g[l];var m=g[l+1];m=""==m||!isNaN(parseInt(m,10));var p=l===g.length-1;""===f&&(f=g.slice(0,l).join(),null==e[f]&&(e[f]=0),f=e[f]++);null==r[f]&&(r[f]=p?n:m?[]:{});r=r[f]}}return d},V=function(b){function d(d){var e=b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,
|
||||
decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(b){return function(){null==g&&(g=f(function(){g=null;b()}))}}function k(b,d,e){var a=b.indexOf("?"),f=b.indexOf("#"),g=-1<a?a:-1<f?f:b.length;if(-1<a){a=M(b.slice(a+1,-1<f?f:b.length));for(var k in a)d[k]=a[k]}if(-1<f)for(k in d=M(b.slice(f+1)),d)e[k]=d[k];return b.slice(0,g)}var n="function"===typeof b.history.pushState,f="function"===typeof setImmediate?setImmediate:setTimeout,g,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,e,f){var a={},g={};d=k(d,a,g);if(null!=e){for(var l in e)a[l]=e[l];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return e[d]})}(l=H(a))&&(d+="?"+l);(g=H(g))&&(d+="#"+g);n?(g=f?f.state:null,l=f?f.title:null,b.onpopstate(),f&&f.replace?b.history.replaceState(g,l,r.prefix+d):b.history.pushState(g,l,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,
|
||||
f,g){function a(){var a=r.getPath(),e={},l=k(a,e,e),p=b.history.state;if(null!=p)for(var m in p)e[m]=p[m];for(var n in d)if(p=new RegExp("^"+n.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(l)){l.replace(p,function(){for(var b=n.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,1,-2),k=0;k<b.length;k++)e[b[k].replace(/:|\./g,"")]=decodeURIComponent(g[k]);f(d[n],e,a,n)});return}g(a,e)}n?b.onpopstate=e(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};A.route=
|
||||
function(b,d){var e=V(b),k=function(b){return b},n,f,g,r,l,m=function(b,a,m){function p(){null!=n&&d.render(b,n(y(f,g.key,g)))}if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var w=function(){p();w=d.redraw};d.subscribe(b,p);var z=function(b){if(b!==a)e.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+a);};e.defineRoutes(m,function(a,b,d){var e=l=function(a,p){e===l&&(f=null==p||"function"!==typeof p.view&&"function"!==
|
||||
typeof p?"div":p,g=b,r=d,l=null,n=(a.render||k).bind(a),w())};a.view||"function"===typeof a?e({},a):a.onmatch?U.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},z):e(a,"div")},z)};m.set=function(b,a,d){null!=l&&(d=d||{},d.replace=!0);l=null;e.setPath(b,a,d)};m.get=function(){return r};m.prefix=function(b){e.prefix=b};m.link=function(b){b.dom.setAttribute("href",e.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(e.prefix)&&(a=a.slice(e.prefix.length)),m.set(a,void 0,void 0))}};m.param=function(b){return"undefined"!==typeof g&&"undefined"!==typeof b?g[b]:g};return m}(window,I);A.withAttr=function(b,d,e){return function(k){d.call(e||this,b in k.currentTarget?k.currentTarget[b]:k.currentTarget.getAttribute(b))}};var W=Q(window);A.render=W.render;A.redraw=I.redraw;A.request=L.request;A.jsonp=L.jsonp;A.parseQueryString=M;A.buildQueryString=H;A.version="1.1.3";A.vnode=y;"undefined"!==typeof module?
|
||||
module.exports=A:window.m=A})();
|
||||
"");Array.isArray(b)||(b=[b]);f(a,a.vnodes,y.normalizeChildren(b),!1,c,null,"http://www.w3.org/1999/xhtml"===e?void 0:e);a.vnodes=b;for(e=0;e<c.length;e++)c[e]();null!=d&&x.activeElement!==d&&d.focus()},setEventCallback:function(a){return C=a}}},I=function(b,d){function e(b){b=f.indexOf(b);-1<b&&f.splice(b,2)}function k(){if(g)throw Error("Nested m.redraw.sync() call");g=!0;for(var b=1;b<f.length;b+=2)try{f[b]()}catch(m){}g=!1}var n=Q(b);n.setEventCallback(function(b){!1===b.redraw?b.redraw=void 0:
|
||||
r()});var f=[],g=!1,r=(d||S)(k);r.sync=k;return{subscribe:function(b,d){e(b);f.push(b,d)},unsubscribe:e,redraw:r,render:n.render}}(window);L.setCompletionCallback(I.redraw);A.mount=function(b){return function(d,e){if(null===e)b.render(d,[]),b.unsubscribe(d);else{if(null==e.view&&"function"!==typeof e)throw Error("m.mount(element, component) expects a component, not a vnode");var k=function(){b.render(d,y(e))};b.subscribe(d,k);k()}}}(I);var U=w,M=function(b){if(""===b||null==b)return{};"?"===b.charAt(0)&&
|
||||
(b=b.slice(1));b=b.split("&");for(var d={},e={},k=0;k<b.length;k++){var n=b[k].split("=");var f=decodeURIComponent(n[0]);n=2===n.length?decodeURIComponent(n[1]):"";"true"===n?n=!0:"false"===n&&(n=!1);var g=f.split(/\]\[?|\[/),r=d;-1<f.indexOf("[")&&g.pop();for(var l=0;l<g.length;l++){f=g[l];var m=g[l+1];m=""==m||!isNaN(parseInt(m,10));var p=l===g.length-1;""===f&&(f=g.slice(0,l).join(),null==e[f]&&(e[f]=0),f=e[f]++);null==r[f]&&(r[f]=p?n:m?[]:{});r=r[f]}}return d},V=function(b){function d(d){var e=
|
||||
b.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==e[0]&&(e="/"+e);return e}function e(b){return function(){null==g&&(g=f(function(){g=null;b()}))}}function k(b,d,e){var a=b.indexOf("?"),f=b.indexOf("#"),g=-1<a?a:-1<f?f:b.length;if(-1<a){a=M(b.slice(a+1,-1<f?f:b.length));for(var k in a)d[k]=a[k]}if(-1<f)for(k in d=M(b.slice(f+1)),d)e[k]=d[k];return b.slice(0,g)}var n="function"===typeof b.history.pushState,f="function"===typeof setImmediate?setImmediate:setTimeout,
|
||||
g,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,e,f){var a={},g={};d=k(d,a,g);if(null!=e){for(var l in e)a[l]=e[l];d=d.replace(/:([^\/]+)/g,function(b,d){delete a[d];return e[d]})}(l=H(a))&&(d+="?"+l);(g=H(g))&&(d+="#"+g);n?(g=f?f.state:null,l=f?f.title:null,b.onpopstate(),f&&f.replace?
|
||||
b.history.replaceState(g,l,r.prefix+d):b.history.pushState(g,l,r.prefix+d)):b.location.href=r.prefix+d},defineRoutes:function(d,f,g){function a(){var a=r.getPath(),e={},l=k(a,e,e),p=b.history.state;if(null!=p)for(var m in p)e[m]=p[m];for(var n in d)if(p=new RegExp("^"+n.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),p.test(l)){l.replace(p,function(){for(var b=n.match(/:[^\/]+/g)||[],g=[].slice.call(arguments,1,-2),k=0;k<b.length;k++)e[b[k].replace(/:|\./g,"")]=decodeURIComponent(g[k]);
|
||||
f(d[n],e,a,n)});return}g(a,e)}n?b.onpopstate=e(a):"#"===r.prefix.charAt(0)&&(b.onhashchange=a);a()}};return r};A.route=function(b,d){var e=V(b),k=function(b){return b},n,f,g,r,l,m=function(b,a,m){function p(){null!=n&&d.render(b,n(y(f,g.key,g)))}if(null==b)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var w=function(){p();w=d.redraw};d.subscribe(b,p);var z=function(b){if(b!==a)e.setPath(a,null,{replace:!0});else throw Error("Could not resolve default route "+
|
||||
a);};e.defineRoutes(m,function(a,b,d){var e=l=function(a,p){e===l&&(f=null==p||"function"!==typeof p.view&&"function"!==typeof p?"div":p,g=b,r=d,l=null,n=(a.render||k).bind(a),w())};a.view||"function"===typeof a?e({},a):a.onmatch?U.resolve(a.onmatch(b,d)).then(function(b){e(a,b)},z):e(a,"div")},z)};m.set=function(b,a,d){null!=l&&(d=d||{},d.replace=!0);l=null;e.setPath(b,a,d)};m.get=function(){return r};m.prefix=function(b){e.prefix=b};m.link=function(b){b.dom.setAttribute("href",e.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(e.prefix)&&(a=a.slice(e.prefix.length)),m.set(a,void 0,void 0))}};m.param=function(b){return"undefined"!==typeof g&&"undefined"!==typeof b?g[b]:g};return m}(window,I);A.withAttr=function(b,d,e){return function(k){d.call(e||this,b in k.currentTarget?k.currentTarget[b]:k.currentTarget.getAttribute(b))}};var W=Q(window);A.render=W.render;A.redraw=I.redraw;
|
||||
A.request=L.request;A.jsonp=L.jsonp;A.parseQueryString=M;A.buildQueryString=H;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