ensure type option only applies to successful responses
This commit is contained in:
parent
8bba1dc9d9
commit
55514c3557
1 changed files with 5 additions and 3 deletions
|
|
@ -519,10 +519,12 @@ Mithril = m = new function app(window) {
|
|||
e = e || event
|
||||
var unwrap = (e.type == "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity
|
||||
var response = unwrap(deserialize(extract(e.target, xhrOptions)))
|
||||
if (response instanceof Array && xhrOptions.type) {
|
||||
for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i])
|
||||
if (e.type == "load") {
|
||||
if (response instanceof Array && xhrOptions.type) {
|
||||
for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i])
|
||||
}
|
||||
else if (xhrOptions.type) response = new xhrOptions.type(response)
|
||||
}
|
||||
else if (xhrOptions.type) response = new xhrOptions.type(response)
|
||||
deferred[e.type == "load" ? "resolve" : "reject"](response)
|
||||
}
|
||||
catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue