diff --git a/README.md b/README.md index 9664d8f4..913fdfe3 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,6 @@ There are over 4000 assertions in the test suite, and tests cover even difficult ## Modularity -Despite the huge improvements in performance and modularity, the new codebase is smaller than v0.2.x, currently clocking at 7.54 KB min+gzip +Despite the huge improvements in performance and modularity, the new codebase is smaller than v0.2.x, currently clocking at 7.55 KB min+gzip In addition, Mithril is now completely modular: you can import only the modules that you need and easily integrate 3rd party modules if you wish to use a different library for routing, ajax, and even rendering diff --git a/api/tests/test-router.js b/api/tests/test-router.js index 7e2454cb..d70a7c23 100644 --- a/api/tests/test-router.js +++ b/api/tests/test-router.js @@ -51,7 +51,7 @@ o.spec("route", function() { o(root.firstChild.nodeName).equals("DIV") }) - o("routed mount points can redraw synchronoulsy (#1275)", function() { + o("routed mount points can redraw synchronously (#1275)", function() { var view = o.spy() $window.location.href = prefix + "/" @@ -66,7 +66,9 @@ o.spec("route", function() { }) o("default route doesn't break back button", function(done) { - $window.location.href = "http://google.com" + $window.location.href = "http://old.com" + $window.location.href = "http://new.com" + route(root, "/a", { "/a" : { view: function() { @@ -78,9 +80,12 @@ o.spec("route", function() { callAsync(function() { o(root.firstChild.nodeName).equals("DIV") + o(route.get()).equals("/a") + $window.history.back() o($window.location.pathname).equals("/") + o($window.location.hostname).equals("old.com") done() }) @@ -574,7 +579,7 @@ o.spec("route", function() { o(matchCount).equals(1) o(renderCount).equals(2) - + done() }) }) @@ -609,7 +614,7 @@ o.spec("route", function() { o(matchCount).equals(1) o(renderCount).equals(2) - + done() }) }) @@ -617,7 +622,7 @@ o.spec("route", function() { o("onmatch can redirect to another route", function(done) { var redirected = false var render = o.spy() - + $window.location.href = prefix + "/a" route(root, "/a", { "/a" : { @@ -968,7 +973,7 @@ o.spec("route", function() { o(renderA.callCount).equals(0) o(renderB.callCount).equals(1) - done() + done() }) }, 20) }) @@ -1190,19 +1195,19 @@ o.spec("route", function() { } }, }) - + callAsync(function() { // tick for popstate for /a callAsync(function() { // tick for promise in onmatch callAsync(function() { // tick for onpopstate for /b o(rendered).equals(false) o(resolved).equals("b") - + done() }) }) }) }) - + o("throttles", function(done, timeout) { timeout(200) diff --git a/index.js b/index.js index d849a317..6e69cea4 100644 --- a/index.js +++ b/index.js @@ -16,5 +16,6 @@ m.jsonp = requestService.jsonp m.parseQueryString = require("./querystring/parse") m.buildQueryString = require("./querystring/build") m.version = "bleeding-edge" +m.vnode = require("./render/vnode") module.exports = m diff --git a/mithril.js b/mithril.js index 715ecc63..104a4dac 100644 --- a/mithril.js +++ b/mithril.js @@ -1098,7 +1098,7 @@ var _20 = function($window, redrawService0) { if (render1 != null) redrawService0.render(root, render1(Vnode(component, attrs3.key, attrs3))) } var bail = function() { - routeService.setPath(defaultRoute) + routeService.setPath(defaultRoute, null, { replace: true }) } routeService.defineRoutes(routes, function(payload, params, path) { var update = lastUpdate = function(routeResolver, comp) { @@ -1153,6 +1153,7 @@ m.jsonp = requestService.jsonp m.parseQueryString = parseQueryString m.buildQueryString = buildQueryString m.version = "1.0.0-rc.6" +m.vnode = Vnode if (typeof module !== "undefined") module["exports"] = m else window.m = m } \ No newline at end of file diff --git a/mithril.min.js b/mithril.min.js index 811aaac4..dc602474 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,41 +1,41 @@ -new function(){function u(a,c,h,d,g,m){return{tag:a,key:c,attrs:h,children:d,text:g,dom:m,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function A(a){if(null==a||"string"!==typeof a&&null==a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===J[a]){for(var c,h,d=[],g={};c=P.exec(a);){var m=c[1],l=c[2];""===m&&""!==l?h=l:"#"===m?g.id=l:"."===m?d.push(l):"["===c[3][0]&&((m=c[6])&&(m=m.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")), +new function(){function u(a,c,h,d,g,m){return{tag:a,key:c,attrs:h,children:d,text:g,dom:m,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function z(a){if(null==a||"string"!==typeof a&&null==a.view)throw Error("The selector must be either a string or a component.");if("string"===typeof a&&void 0===J[a]){for(var c,h,d=[],g={};c=P.exec(a);){var m=c[1],l=c[2];""===m&&""!==l?h=l:"#"===m?g.id=l:"."===m?d.push(l):"["===c[3][0]&&((m=c[6])&&(m=m.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")), "class"===c[4]?d.push(m):g[c[4]]=m||!0)}0a.indexOf("?")?"?":"&";a+=d+b}return a}function l(a){try{return""!==a?JSON.parse(a):null}catch(C){throw Error(a);}}function n(a){return a.responseText}function p(a, c){if("function"===typeof a)if(c instanceof Array)for(var b=0;bk.status||304===k.status)c(p(b.type,a));else{var g=Error(k.responseText),h;for(h in a)g[h]=a[h];d(g)}}catch(E){d(E)}};h&&null!=b.data?k.send(b.data):k.send()});return!0===b.background?w:t(w)},jsonp:function(b,l){var n=h();b=d(b,l);var t=new c(function(c, d){var h=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+k++,l=a.document.createElement("script");a[h]=function(d){l.parentNode.removeChild(l);c(p(b.type,d));delete a[h]};l.onerror=function(){l.parentNode.removeChild(l);d(Error("JSONP request failed"));delete a[h]};null==b.data&&(b.data={});b.url=g(b.url,b.data);b.data[b.callbackKey||"callback"]=h;l.src=m(b.url,b.data);a.document.documentElement.appendChild(l)});return!0===b.background?t:n(t)},setCompletionCallback:function(a){t=a}}}(window, -G),O=function(a){function c(e,f,a,b,c,d,g){for(;a=k&&w>=B;){var v=f[k],q=a[B];if(v!==q||r)if(null==v)k++;else if(null==q)B++;else if(v.key===q.key)k++,B++,m(e,v,q,b,n(f,k,d),r,g),r&&v.tag===q.tag&&p(e,l(v),d);else if(v=f[x],v!==q||r)if(null==v)x--;else if(null==q)B++;else if(v.key===q.key)m(e,v,q,b,n(f,x+1,d),r,g),(r||B=k&&w>=B;){v=f[x];q=a[w]; if(v!==q||r)if(null==v)x--;else{if(null!=q)if(v.key===q.key)m(e,v,q,b,n(f,x+1,d),r,g),r&&v.tag===q.tag&&p(e,l(v),d),null!=v.dom&&(d=v.dom),x--;else{if(!C){C=f;var v=x,y={},F;for(F=0;F