Skip to content

Commit 6c705ba

Browse files
With switching to can-reflect, needed to reduce to get the same result
1 parent d7b734f commit 6c705ba

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

can-ajax.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ var param = require("can-param");
3636
* - __data__ `{Object}` The data of the request. If data needs to be urlencoded (e.g. for GET requests or for CORS) it is serialized with [can-param].
3737
* - __dataType__ `{String}` Type of data. _Default is `json`_.
3838
* - __crossDomain__ `{Boolean}` If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain. Default: `false` for same-domain requests, `true` for cross-domain requests.
39-
* - __xhrFields__ `{Object}` Any fields to be set directly on the xhr request, [https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest] such as the withCredentials attribute that indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.
40-
*
39+
* - __xhrFields__ `{Object}` Any fields to be set directly on the xhr request, [https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest] such as the withCredentials attribute that indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers.
40+
*
4141
* @return {Promise} A Promise that resolves to the data. The Promise instance is abortable and exposes an `abort` method. Invoking abort on the Promise instance indirectly rejects it.
4242
*
4343
*
4444
* @signature `ajaxSetup( ajaxOptions )`
4545
*
46-
* Is used to persist ajaxOptions across all ajax requests and they can be over-written in the ajaxOptions of the actual request.
46+
* Is used to persist ajaxOptions across all ajax requests and they can be over-written in the ajaxOptions of the actual request.
4747
* [https://api.jquery.com/jquery.ajaxsetup/]
4848
*
4949
* ```
@@ -129,13 +129,15 @@ function ajax(o) {
129129
xhr.abort();
130130
};
131131

132-
o = canReflect.assignDeep({
133-
userAgent: "XMLHttpRequest",
134-
lang: "en",
135-
type: "GET",
136-
data: null,
137-
dataType: "json"
138-
}, globalSettings, o);
132+
o = [{
133+
userAgent: "XMLHttpRequest",
134+
lang: "en",
135+
type: "GET",
136+
data: null,
137+
dataType: "json"
138+
}, globalSettings, o].reduce(function(a,b,i) {
139+
return canReflect.assignDeep(a,b);
140+
});
139141

140142
// Set the default contentType
141143
if(!o.contentType) {

test.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<!DOCTYPE html>
12
<title>can-ajax</title>
23
<script src="node_modules/steal/steal.js" main="can-ajax/can-ajax-test"></script>
34
<div id="qunit-fixture"></div>

0 commit comments

Comments
 (0)