m.request default parameter allows immediate invocation of returned m.prop
This commit is contained in:
parent
1053b70d3e
commit
71a6321c46
2 changed files with 10 additions and 0 deletions
|
|
@ -949,6 +949,7 @@ Mithril = m = new function app(window, undefined) {
|
|||
if (xhrOptions.background !== true) m.endComputation()
|
||||
}
|
||||
ajax(xhrOptions)
|
||||
deferred.promise(xhrOptions.default)
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1687,6 +1687,15 @@ function testMithril(mock) {
|
|||
xhr.onreadystatechange()
|
||||
return xhr.$headers["Content-Type"] === undefined
|
||||
})
|
||||
test(function() {
|
||||
var prop = m.request({method: "POST", url: "test", default: "foo"})
|
||||
return prop() === "foo"
|
||||
})
|
||||
test(function() {
|
||||
var prop = m.request({method: "POST", url: "test", default: "foo"}).then(function(value) {return "bar"})
|
||||
mock.XMLHttpRequest.$instances.pop().onreadystatechange()
|
||||
return prop() === "bar"
|
||||
})
|
||||
|
||||
// m.request over jsonp
|
||||
test(function(){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue