diff --git a/docs/request.md b/docs/request.md index c2df2017..4653e9c0 100644 --- a/docs/request.md +++ b/docs/request.md @@ -22,7 +22,7 @@ Argument | Type | Required | Description ---------------------- | --------------------------------- | -------- | --- `url` | `String` | No | If present, it's equivalent to having the options `{method: "GET", url: url}`. Values passed to the `options` argument override options set via this shorthand. -`options.method` | `String` | Yes | The HTTP method to use. This value should be one of the following: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. +`options.method` | `String` | No | The HTTP method to use. This value should be one of the following: `GET`, `POST`, `PUT`, `PATCH`, `DELETE`, `HEAD` or `OPTIONS`. Defaults to `GET`. `options.url` | `String` | Yes | The URL to send the request to. The URL may be either absolute or relative, and it may contain [interpolations](#dynamic-urls). `options.data` | `any` | No | The data to be interpolated into the URL and serialized into the querystring (for GET requests) or body (for other types of requests). `options.async` | `Boolean` | No | Whether the request should be asynchronous. Defaults to `true`. diff --git a/mithril.js b/mithril.js index 87f969f0..e8a90fad 100644 --- a/mithril.js +++ b/mithril.js @@ -219,11 +219,10 @@ var _8 = function($window, Promise) { return finalize(new Promise(function(resolve, reject) { if (typeof args === "string") { var url = args - if (typeof extra === "object") args = extra - else args = {} - if (typeof args.url === "undefined") args.url = url + args = extra || {} + if (args.url == null) args.url = url } - if (typeof args.method === "undefined") args.method = "GET" + if (args.method == null) args.method = "GET" args.method = args.method.toUpperCase() var useBody = typeof args.useBody === "boolean" ? args.useBody : args.method !== "GET" && args.method !== "TRACE" if (typeof args.serialize !== "function") args.serialize = typeof FormData !== "undefined" && args.data instanceof FormData ? function(value) {return value} : JSON.stringify @@ -540,7 +539,7 @@ var _14 = function($window) { } else { removeNode(old, null) - insertNode(parent, createNode(vnode, hooks, undefined), nextSibling) + insertNode(parent, createNode(vnode, hooks, ns), nextSibling) } } function updateText(old, vnode) { diff --git a/mithril.min.js b/mithril.min.js index 229551ce..629dd000 100644 --- a/mithril.min.js +++ b/mithril.min.js @@ -7,34 +7,34 @@ var d=this,l=[],h=[],u=b(l,!0),q=b(h,!1),r=d._instance={resolvers:l,rejectors:h} a)};z.resolve=function(a){return a instanceof z?a:new z(function(b){b(a)})};z.reject=function(a){return new z(function(b,k){k(a)})};z.all=function(a){return new z(function(b,k){var d=a.length,l=0,h=[];if(0===a.length)b([]);else for(var u=0;ua.indexOf("?")?"?":"&";a+=d+f}return a}function u(a){try{return""!==a?JSON.parse(a):null}catch(w){throw Error(a);}}function q(a){return a.responseText} -function r(a,b){if("function"===typeof a)if(b instanceof Array)for(var d=0;dp.status||304===p.status)b(r(f.type,a));else{var h=Error(p.responseText),k;for(k in a)h[k]=a[k];d(h)}}catch(G){d(G)}};n&&null!=f.data?p.send(f.data):p.send()}))},jsonp:function(f){return d(new b(function(b, -d){var k=f.callbackName||"_mithril_"+Math.round(1E16*Math.random())+"_"+m++,p=a.document.createElement("script");a[k]=function(d){p.parentNode.removeChild(p);b(r(f.type,d));delete a[k]};p.onerror=function(){p.parentNode.removeChild(p);d(Error("JSONP request failed"));delete a[k]};null==f.data&&(f.data={});f.url=l(f.url,f.data);f.data[f.callbackKey||"callback"]=k;p.src=h(f.url,f.data);a.document.documentElement.appendChild(p)}))},setCompletionCallback:function(a){v=a}}}(window,C),K=function(){var a= -[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b=a.indexOf(b);-1=l&&B>=A;){var x=a[l],m=e[A];if(x!==m||g)if(null!=x&&null!=m&&x.key===m.key)l++,A++,h(c,x,m,f,q(a,l,d),g,p),g&&x.tag===m.tag&&r(c,u(x),d);else if(x=a[v],x!==m||g)if(null!= -x&&null!=m&&x.key===m.key)h(c,x,m,f,q(a,v+1,d),g,p),(g||A=l&&B>=A;){x=a[v];m=e[B];if(x!==m||g)if(null!=x&&null!=m&&x.key===m.key)h(c,x,m,f,q(a,v+1,d),g,p),g&&x.tag===m.tag&&r(c,u(x),d),null!=x.dom&&(d=x.dom),v--;else{if(!w){w=a;var x=v,D={},t;for(t=0;tp.status||304===p.status)b(r(f.type,a));else{var h=Error(p.responseText),k;for(k in a)h[k]=a[k];d(h)}}catch(G){d(G)}};n&&null!=f.data?p.send(f.data):p.send()}))},jsonp:function(f){return d(new b(function(b,d){var p=f.callbackName||"_mithril_"+Math.round(1E16* +Math.random())+"_"+m++,k=a.document.createElement("script");a[p]=function(d){k.parentNode.removeChild(k);b(r(f.type,d));delete a[p]};k.onerror=function(){k.parentNode.removeChild(k);d(Error("JSONP request failed"));delete a[p]};null==f.data&&(f.data={});f.url=l(f.url,f.data);f.data[f.callbackKey||"callback"]=p;k.src=h(f.url,f.data);a.document.documentElement.appendChild(k)}))},setCompletionCallback:function(a){v=a}}}(window,C),K=function(){var a=[];return{subscribe:a.push.bind(a),unsubscribe:function(b){b= +a.indexOf(b);-1=l&&B>=A;){var x=a[l],m=e[A];if(x!==m||g)if(null!=x&&null!=m&&x.key===m.key)l++,A++,h(c,x,m,f,q(a,l,d),g,p),g&&x.tag===m.tag&&r(c,u(x),d);else if(x=a[v],x!==m||g)if(null!=x&&null!=m&&x.key===m.key)h(c,x,m,f,q(a,v+1,d),g,p),(g||A=l&&B>=A;){x=a[v];m=e[B];if(x!==m||g)if(null!=x&&null!=m&&x.key===m.key)h(c,x,m,f,q(a,v+1,d),g,p),g&&x.tag===m.tag&&r(c,u(x),d),null!=x.dom&&(d=x.dom),v--;else{if(!w){w=a;var x=v,D={},t;for(t=0;t