Bundled output for commit b9639dc485 [skip ci]
This commit is contained in:
parent
b9639dc485
commit
68daa36e71
2 changed files with 9 additions and 8 deletions
|
|
@ -966,7 +966,7 @@ var _16 = function(redrawService0) {
|
|||
return
|
||||
}
|
||||
|
||||
if (component.view == null) throw new Error("m.mount(element, component) expects a component, not a vnode")
|
||||
if (component.view == null && typeof component !== "function") throw new Error("m.mount(element, component) expects a component, not a vnode")
|
||||
|
||||
var run0 = function() {
|
||||
redrawService0.render(root, Vnode(component))
|
||||
|
|
@ -1119,11 +1119,12 @@ var _20 = function($window, redrawService0) {
|
|||
routeService.defineRoutes(routes, function(payload, params, path) {
|
||||
var update = lastUpdate = function(routeResolver, comp) {
|
||||
if (update !== lastUpdate) return
|
||||
component = comp != null && typeof comp.view === "function" ? comp : "div", attrs3 = params, currentPath = path, lastUpdate = null
|
||||
component = comp != null && (typeof comp.view === "function" || typeof comp === "function")? comp : "div"
|
||||
attrs3 = params, currentPath = path, lastUpdate = null
|
||||
render1 = (routeResolver.render || identity).bind(routeResolver)
|
||||
run1()
|
||||
}
|
||||
if (payload.view) update({}, payload)
|
||||
if (payload.view || typeof payload === "function") update({}, payload)
|
||||
else {
|
||||
if (payload.onmatch) {
|
||||
Promise.resolve(payload.onmatch(params, path)).then(function(resolved) {
|
||||
|
|
|
|||
10
mithril.min.js
vendored
10
mithril.min.js
vendored
|
|
@ -32,11 +32,11 @@ d&&(e.style.cssText="",a=null),null==d)e.style.cssText="";else if("string"===typ
|
|||
p.activeElement||"option"===a.tag&&"value"===b&&a.dom.value===d||(e[b]=d):"boolean"===typeof d?d?e.setAttribute(b,""):e.removeAttribute(b):e.setAttribute("className"===b?"class":b,d)}}function D(a){return"oninit"===a||"oncreate"===a||"onupdate"===a||"onremove"===a||"onbeforeremove"===a||"onbeforeupdate"===a}function M(a,b,c){var d=a.dom,e="function"!==typeof I?c:function(a){var b=c.call(d,a);I.call(d,a);return b};if(b in d)d[b]="function"===typeof c?e:null;else{var f=b.slice(2);void 0===a.events&&
|
||||
(a.events={});a.events[b]!==e&&(null!=a.events[b]&&d.removeEventListener(f,a.events[b],!1),"function"===typeof c&&(a.events[b]=e,d.addEventListener(f,a.events[b],!1)))}}function v(a,b,c){"function"===typeof a.oninit&&a.oninit.call(b.state,b);"function"===typeof a.oncreate&&c.push(a.oncreate.bind(b.state,b))}function z(a,b,c,d){d?v(a,b,c):"function"===typeof a.onupdate&&c.push(a.onupdate.bind(b.state,b))}var p=a.document,J=p.createDocumentFragment(),I;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=p.activeElement;null==a.vnodes&&(a.textContent="");Array.isArray(b)||(b=[b]);g(a,a.vnodes,w.normalizeChildren(b),!1,c,null,void 0);a.vnodes=b;for(var f=0;f<c.length;f++)c[f]();p.activeElement!==d&&d.focus()},setEventCallback:function(a){return I=a}}},G=function(a){function d(a){a=f.indexOf(a);-1<a&&f.splice(a,2)}function h(){for(var a=1;a<f.length;a+=2)f[a]()}a=N(a);a.setEventCallback(function(a){!1!==a.redraw&&h()});var f=[];return{subscribe:function(a,h){d(a);f.push(a,P(h))},unsubscribe:d,
|
||||
redraw:h,render:a.render}}(window);K.setCompletionCallback(G.redraw);z.mount=function(a){return function(d,h){if(null===h)a.render(d,[]),a.unsubscribe(d);else{if(null==h.view)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(d,function(){a.render(d,w(h))});a.redraw()}}}(G);var R=v,L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},h={},f=0;f<a.length;f++){var g=a[f].split("="),l=decodeURIComponent(g[0]),g=2===
|
||||
g.length?decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var k=l.split(/\]\[?|\[/),m=d;-1<l.indexOf("[")&&k.pop();for(var n=0;n<k.length;n++){var l=k[n],t=k[n+1],t=""==t||!isNaN(parseInt(t,10)),x=n===k.length-1;""===l&&(l=k.slice(0,n).join(),null==h[l]&&(h[l]=0),l=h[l]++);null==m[l]&&(m[l]=x?g:t?[]:{});m=m[l]}}return d},S=function(a){function d(d){var f=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(a){return function(){null==
|
||||
redraw:h,render:a.render}}(window);K.setCompletionCallback(G.redraw);z.mount=function(a){return function(d,h){if(null===h)a.render(d,[]),a.unsubscribe(d);else{if(null==h.view&&"function"!==typeof h)throw Error("m.mount(element, component) expects a component, not a vnode");a.subscribe(d,function(){a.render(d,w(h))});a.redraw()}}}(G);var R=v,L=function(a){if(""===a||null==a)return{};"?"===a.charAt(0)&&(a=a.slice(1));a=a.split("&");for(var d={},h={},f=0;f<a.length;f++){var g=a[f].split("="),l=decodeURIComponent(g[0]),
|
||||
g=2===g.length?decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var k=l.split(/\]\[?|\[/),m=d;-1<l.indexOf("[")&&k.pop();for(var n=0;n<k.length;n++){var l=k[n],t=k[n+1],t=""==t||!isNaN(parseInt(t,10)),x=n===k.length-1;""===l&&(l=k.slice(0,n).join(),null==h[l]&&(h[l]=0),l=h[l]++);null==m[l]&&(m[l]=x?g:t?[]:{});m=m[l]}}return d},S=function(a){function d(d){var f=a.location[d].replace(/(?:%[a-f89][a-f0-9])+/gim,decodeURIComponent);"pathname"===d&&"/"!==f[0]&&(f="/"+f);return f}function h(a){return function(){null==
|
||||
k&&(k=l(function(){k=null;a()}))}}function f(a,d,f){var c=a.indexOf("?"),g=a.indexOf("#"),k=-1<c?c:-1<g?g:a.length;if(-1<c){var c=L(a.slice(c+1,-1<g?g:a.length)),h;for(h in c)d[h]=c[h]}if(-1<g)for(h in d=L(a.slice(g+1)),d)f[h]=d[h];return a.slice(0,k)}var g="function"===typeof a.history.pushState,l="function"===typeof setImmediate?setImmediate:setTimeout,k,m={prefix:"#!",getPath:function(){switch(m.prefix.charAt(0)){case "#":return d("hash").slice(m.prefix.length);case "?":return d("search").slice(m.prefix.length)+
|
||||
d("hash");default:return d("pathname").slice(m.prefix.length)+d("search")+d("hash")}},setPath:function(d,h,k){var c={},l={};d=f(d,c,l);if(null!=h){for(var n in h)c[n]=h[n];d=d.replace(/:([^\/]+)/g,function(a,d){delete c[d];return h[d]})}(n=F(c))&&(d+="?"+n);(l=F(l))&&(d+="#"+l);g?(l=k?k.state:null,n=k?k.title:null,a.onpopstate(),k&&k.replace?a.history.replaceState(l,n,m.prefix+d):a.history.pushState(l,n,m.prefix+d)):a.location.href=m.prefix+d},defineRoutes:function(d,k,l){function c(){var c=m.getPath(),
|
||||
g={},h=f(c,g,g),n=a.history.state;if(null!=n)for(var x in n)g[x]=n[x];for(var t in d)if(n=new RegExp("^"+t.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),n.test(h)){h.replace(n,function(){for(var a=t.match(/:[^\/]+/g)||[],f=[].slice.call(arguments,1,-2),h=0;h<a.length;h++)g[a[h].replace(/:|\./g,"")]=decodeURIComponent(f[h]);k(d[t],g,c,t)});return}l(c,g)}g?a.onpopstate=h(c):"#"===m.prefix.charAt(0)&&(a.onhashchange=c);c()}};return m};z.route=function(a,d){var h=S(a),f=function(a){return a},
|
||||
g,l,k,m,n,t=function(a,c,t){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var x=function(){null!=g&&d.render(a,g(w(l,k.key,k)))},v=function(a){if(a!==c)h.setPath(c,null,{replace:!0});else throw Error("Could not resolve default route "+c);};h.defineRoutes(t,function(a,c,d){var h=n=function(a,p){h===n&&(l=null!=p&&"function"===typeof p.view?p:"div",k=c,m=d,n=null,g=(a.render||f).bind(a),x())};a.view?h({},a):a.onmatch?R.resolve(a.onmatch(c,d)).then(function(c){h(a,
|
||||
c)},v):h(a,"div")},v);d.subscribe(a,x)};t.set=function(a,c,d){null!=n&&(d={replace:!0});n=null;h.setPath(a,c,d)};t.get=function(){return m};t.prefix=function(a){h.prefix=a};t.link=function(a){a.dom.setAttribute("href",h.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),t.set(a,void 0,void 0))}};t.param=function(a){return"undefined"!==typeof k&&
|
||||
"undefined"!==typeof a?k[a]:k};return t}(window,G);z.withAttr=function(a,d,h){return function(f){d.call(h||this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var T=N(window);z.render=T.render;z.redraw=G.redraw;z.request=K.request;z.jsonp=K.jsonp;z.parseQueryString=L;z.buildQueryString=F;z.version="1.0.1";z.vnode=w;"undefined"!==typeof module?module.exports=z:window.m=z};
|
||||
g,l,k,m,n,t=function(a,c,t){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var x=function(){null!=g&&d.render(a,g(w(l,k.key,k)))},v=function(a){if(a!==c)h.setPath(c,null,{replace:!0});else throw Error("Could not resolve default route "+c);};h.defineRoutes(t,function(a,c,d){var h=n=function(a,p){h===n&&(l=null==p||"function"!==typeof p.view&&"function"!==typeof p?"div":p,k=c,m=d,n=null,g=(a.render||f).bind(a),x())};a.view||"function"===typeof a?h({},
|
||||
a):a.onmatch?R.resolve(a.onmatch(c,d)).then(function(c){h(a,c)},v):h(a,"div")},v);d.subscribe(a,x)};t.set=function(a,c,d){null!=n&&(d={replace:!0});n=null;h.setPath(a,c,d)};t.get=function(){return m};t.prefix=function(a){h.prefix=a};t.link=function(a){a.dom.setAttribute("href",h.prefix+a.attrs.href);a.dom.onclick=function(a){a.ctrlKey||a.metaKey||a.shiftKey||2===a.which||(a.preventDefault(),a.redraw=!1,a=this.getAttribute("href"),0===a.indexOf(h.prefix)&&(a=a.slice(h.prefix.length)),t.set(a,void 0,
|
||||
void 0))}};t.param=function(a){return"undefined"!==typeof k&&"undefined"!==typeof a?k[a]:k};return t}(window,G);z.withAttr=function(a,d,h){return function(f){d.call(h||this,a in f.currentTarget?f.currentTarget[a]:f.currentTarget.getAttribute(a))}};var T=N(window);z.render=T.render;z.redraw=G.redraw;z.request=K.request;z.jsonp=K.jsonp;z.parseQueryString=L;z.buildQueryString=F;z.version="1.0.1";z.vnode=w;"undefined"!==typeof module?module.exports=z:window.m=z};
|
||||
Loading…
Add table
Add a link
Reference in a new issue