From 6a63cb702d7c44fa107fd8dbaa5f7957fb1eae31 Mon Sep 17 00:00:00 2001 From: Gandalf-the-Bot Date: Tue, 6 Dec 2016 15:45:34 +0000 Subject: [PATCH 1/2] Bundled output for commit 846d6ce24b380bea12face9389a059583034d179 [skip ci] --- mithril.js | 5 +++-- mithril.min.js | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/mithril.js b/mithril.js index a473784a..9baf3a09 100644 --- a/mithril.js +++ b/mithril.js @@ -954,6 +954,7 @@ var _16 = function(redrawService0) { } } m.mount = _16(redrawService) +var Promise = PromisePolyfill var parseQueryString = function(string) { if (string === "" || string == null) return {} if (string.charAt(0) === "?") string = string.slice(1) @@ -1135,8 +1136,8 @@ m.withAttr = function(attrName, callback1, context) { return callback1.call(context || this, attrName in e.currentTarget ? e.currentTarget[attrName] : e.currentTarget.getAttribute(attrName)) } } -var _27 = coreRenderer(window) -m.render = _27.render +var _28 = coreRenderer(window) +m.render = _28.render m.redraw = redrawService.redraw m.request = requestService.request m.jsonp = requestService.jsonp diff --git a/mithril.min.js b/mithril.min.js index 0b8fec4e..65d7de53 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -1,21 +1,21 @@ -new function(){function r(a,c,h,d,g,l){return{tag:a,key:c,attrs:h,children:d,text:g,dom:l,domSize:void 0,state:{},events:void 0,instance:void 0,skip:!1}}function y(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===I[a]){for(var c,h,d=[],g={};c=P.exec(a);){var l=c[1],m=c[2];""===l&&""!==m?h=m:"#"===l?g.id=m:"."===l?d.push(m):"["===c[3][0]&&((l=c[6])&&(l=l.replace(/\\(["'])/g,"$1").replace(/\\\\/g,"\\")), -"class"===c[4]?d.push(l):g[c[4]]=l||!0)}0a.indexOf("?")?"?":"&";a+=d+b}return a}function m(a){try{return""!==a?JSON.parse(a):null}catch(M){throw Error(a);}}function A(a){return a.responseText}function n(a,c){if("function"=== -typeof a)if(c instanceof Array)for(var b=0;bk.status||304===k.status)c(n(b.type,a));else{var g=Error(k.responseText),h;for(h in a)g[h]=a[h];d(g)}}catch(F){d(F)}};h&&null!=b.data?k.send(b.data):k.send()});return!0===b.background?u:v(u)},jsonp:function(b,k){var m=h();b=d(b,k);var u=new c(function(c,d){var k=b.callbackName|| -"_mithril_"+Math.round(1E16*Math.random())+"_"+r++,h=a.document.createElement("script");a[k]=function(d){h.parentNode.removeChild(h);c(n(b.type,d));delete a[k]};h.onerror=function(){h.parentNode.removeChild(h);d(Error("JSONP request failed"));delete a[k]};null==b.data&&(b.data={});b.url=g(b.url,b.data);b.data[b.callbackKey||"callback"]=k;h.src=l(b.url,b.data);a.document.documentElement.appendChild(h)});return!0===b.background?u:m(u)},setCompletionCallback:function(a){k=a}}}(window,"undefined"!==typeof Promise? -Promise:t),O=function(a){function c(e,f,a,b,c,d,g){for(;aa.indexOf("?")?"?":"&";a+=d+b}return a}function m(a){try{return""!==a?JSON.parse(a):null}catch(O){throw Error(a);}}function A(a){return a.responseText}function n(a, +c){if("function"===typeof a)if(c instanceof Array)for(var b=0;bk.status||304===k.status)c(n(b.type,a));else{var g=Error(k.responseText),h;for(h in a)g[h]=a[h];d(g)}}catch(F){d(F)}};h&&null!=b.data?k.send(b.data):k.send()});return!0===b.background?u:v(u)},jsonp:function(b,k){var m=h();b=d(b,k);var u=new c(function(c, +d){var k=b.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+r++,h=a.document.createElement("script");a[k]=function(d){h.parentNode.removeChild(h);c(n(b.type,d));delete a[k]};h.onerror=function(){h.parentNode.removeChild(h);d(Error("JSONP request failed"));delete a[k]};null==b.data&&(b.data={});b.url=g(b.url,b.data);b.data[b.callbackKey||"callback"]=k;h.src=l(b.url,b.data);a.document.documentElement.appendChild(h)});return!0===b.background?u:m(u)},setCompletionCallback:function(a){k=a}}}(window, +H),Q=function(a){function c(e,f,a,b,c,d,g){for(;a=w&&v>=u;){var x=f[w],p=a[u];if(x!==p||q)if(null==x)w++;else if(null==p)u++;else if(x.key===p.key)w++,u++,l(e,x,p,b,A(f,w,d),q,g),q&&x.tag===p.tag&&n(e,m(x),d);else if(x=f[z],x!==p||q)if(null==x)z--;else if(null==p)u++;else if(x.key===p.key)l(e,x,p,b,A(f,z+1,d),q,g),(q||u=w&&v>=u;){x=f[z];p=a[v];if(x!==p||q)if(null==x)z--;else{if(null!= p)if(x.key===p.key)l(e,x,p,b,A(f,z+1,d),q,g),q&&x.tag===p.tag&&n(e,m(x),d),null!=x.dom&&(d=x.dom),z--;else{if(!D){D=f;var x=z,r={},C;for(C=0;C Date: Tue, 6 Dec 2016 16:48:43 +0000 Subject: [PATCH 2/2] Document m.deferred removal --- docs/change-log.md | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/docs/change-log.md b/docs/change-log.md index ea2ee425..0475c996 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -27,6 +27,7 @@ If you are migrating, consider using the [mithril-codemods](https://www.npmjs.co - [Accessing route params](#accessing-route-params) - [Preventing unmounting](#preventing-unmounting) - [`m.request`](#mrequest) +- [`m.deferred` removed](#mdeferred-removed) - [`m.sync` removed](#msync-removed) - [`xlink` namespace required](#xlink-namespace-required) - [Nested arrays in views](#nested-arrays-in-views) @@ -502,9 +503,45 @@ Additionally, if the `extract` option is passed to `m.request` the return value --- +## `m.deferred` removed + +`v0.2.x` used its own custom asynchronous contract object, exposed as `m.deferred`, which was used as the basis for `m.request`. `v1.x` uses Promises instead, and implements a [polyfill](promises.md) in non-supporting environments. In situations where you would have used `m.deferred`, you should use Promises instead. + +### `v0.2.x` + +```javascript +var greetAsync = function() { + var deferred = m.deferred(); + setTimeout(function() { + deferred.resolve("hello"); + }, 1000); + return deferred.promise; +}; + +greetAsync() + .then(function(value) {return value + " world"}) + .then(function(value) {console.log(value)}); //logs "hello world" after 1 second +``` + +### `v1.x` + +```javascript +var greetAsync = new Promise(function(resolve){ + setTimeout(function() { + resolve("hello"); + }, 1000); +}); + +greetAsync() + .then(function(value) {return value + " world"}) + .then(function(value) {console.log(value)}); //logs "hello world" after 1 second +``` + +--- + ## `m.sync` removed -`m.sync` has been removed in favor of `Promise.all` +Since `v1.x` uses standards-compliant Promises, `m.sync` is redundant. Use `Promise.all` instead. ### `v0.2.x` @@ -570,7 +607,7 @@ If a vnode is strictly equal to the vnode occupying its place in the last draw, ## `m.startComputation`/`m.endComputation` removed -They are considered anti-patterns and have a number of problematic edge cases, so they no longer exist in v1.x +They are considered anti-patterns and have a number of problematic edge cases, so they no longer exist in v1.x. ---