Fix back button for default route.
This commit is contained in:
parent
bc01dad847
commit
b6daeaab5a
3 changed files with 5 additions and 5 deletions
6
mithril.min.js
vendored
6
mithril.min.js
vendored
|
|
@ -36,6 +36,6 @@ decodeURIComponent(g[1]):"";"true"===g?g=!0:"false"===g&&(g=!1);var l=m.split(/\
|
|||
l&&(l=m(function(){l=null;a()}))}}function d(a,c,d){var b=a.indexOf("?"),g=a.indexOf("#"),k=-1<b?b:-1<g?g:a.length;if(-1<b){var b=L(a.slice(b+1,-1<g?g:a.length)),h;for(h in b)c[h]=b[h]}if(-1<g)for(h in c=L(a.slice(g+1)),c)d[h]=c[h];return a.slice(0,k)}var g="function"===typeof a.history.pushState,m="function"===typeof setImmediate?setImmediate:setTimeout,l,n={prefix:"#!",getPath:function(){switch(n.prefix.charAt(0)){case "#":return c("hash").slice(n.prefix.length);case "?":return c("search").slice(n.prefix.length)+
|
||||
c("hash");default:return c("pathname").slice(n.prefix.length)+c("search")+c("hash")}},setPath:function(c,k,h){var b={},l={};c=d(c,b,l);if(null!=k){for(var q in k)b[q]=k[q];c=c.replace(/:([^\/]+)/g,function(a,c){delete b[c];return k[c]})}(q=H(b))&&(c+="?"+q);(l=H(l))&&(c+="#"+l);g?(l=h?h.state:null,q=h?h.title:null,a.onpopstate(),h&&h.replace?a.history.replaceState(l,q,n.prefix+c):a.history.pushState(l,q,n.prefix+c)):a.location.href=n.prefix+c},defineRoutes:function(c,k,l){function b(){var b=n.getPath(),
|
||||
g={},h=d(b,g,g),m=a.history.state;if(null!=m)for(var t in m)g[t]=m[t];for(var p in c)if(m=new RegExp("^"+p.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$"),m.test(h)){h.replace(m,function(){for(var a=p.match(/:[^\/]+/g)||[],d=[].slice.call(arguments,1,-2),h=0;h<a.length;h++)g[a[h].replace(/:|\./g,"")]=decodeURIComponent(d[h]);k(c[p],g,b,p)});return}l(b,g)}g?a.onpopstate=h(b):"#"===n.prefix.charAt(0)&&(a.onhashchange=b);b()}};return n};z.route=function(a,c){var h=T(a),d=function(a){return a},
|
||||
g,m,l,n,p,k=function(a,b,k){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var q=function(){null!=g&&c.render(a,g(u(m,l.key,l)))},t=function(){h.setPath(b)};h.defineRoutes(k,function(a,b,c){var h=p=function(a,k){h===p&&(m=null!=k&&"function"===typeof k.view?k:"div",l=b,n=c,p=null,g=(a.render||d).bind(a),q())};a.view?h({},a):a.onmatch?D.resolve(a.onmatch(b,c)).then(function(b){h(a,b)},t):h(a,"div")},t);c.subscribe(a,q)};k.set=function(a,b,c){null!=p&&
|
||||
(c={replace:!0});p=null;h.setPath(a,b,c)};k.get=function(){return n};k.prefix=function(a){h.prefix=a};k.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)),k.set(a,void 0,void 0))}};return k}(window,I);z.withAttr=function(a,c,h){return function(d){return c.call(h||this,a in d.currentTarget?d.currentTarget[a]:
|
||||
d.currentTarget.getAttribute(a))}};G=O(window);z.render=G.render;z.redraw=I.redraw;z.request=K.request;z.jsonp=K.jsonp;z.parseQueryString=L;z.buildQueryString=H;z.version="1.0.0-rc.6";z.vnode=u;"undefined"!==typeof module?module.exports=z:window.m=z};
|
||||
g,m,l,n,p,k=function(a,b,k){if(null==a)throw Error("Ensure the DOM element that was passed to `m.route` is not undefined");var q=function(){null!=g&&c.render(a,g(u(m,l.key,l)))},t=function(){h.setPath(b,null,{replace:!0})};h.defineRoutes(k,function(a,b,c){var h=p=function(a,k){h===p&&(m=null!=k&&"function"===typeof k.view?k:"div",l=b,n=c,p=null,g=(a.render||d).bind(a),q())};a.view?h({},a):a.onmatch?D.resolve(a.onmatch(b,c)).then(function(b){h(a,b)},t):h(a,"div")},t);c.subscribe(a,q)};k.set=function(a,
|
||||
b,c){null!=p&&(c={replace:!0});p=null;h.setPath(a,b,c)};k.get=function(){return n};k.prefix=function(a){h.prefix=a};k.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)),k.set(a,void 0,void 0))}};return k}(window,I);z.withAttr=function(a,c,h){return function(d){return c.call(h||this,a in d.currentTarget?
|
||||
d.currentTarget[a]:d.currentTarget.getAttribute(a))}};G=O(window);z.render=G.render;z.redraw=I.redraw;z.request=K.request;z.jsonp=K.jsonp;z.parseQueryString=L;z.buildQueryString=H;z.version="1.0.0-rc.6";z.vnode=u;"undefined"!==typeof module?module.exports=z:window.m=z};
|
||||
Loading…
Add table
Add a link
Reference in a new issue