Fix #873, regenerate minified variants.
Drive-by fix: uppercase tag name in failing m.trust test (doesn't make it pass, though).
This commit is contained in:
parent
747ba7e6d9
commit
cb29a21ec3
5 changed files with 49 additions and 14 deletions
17
mithril.js
17
mithril.js
|
|
@ -2115,7 +2115,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
options.onload = options.onerror = function (ev) {
|
||||
ev = ev || event
|
||||
var doSuccess = ev.type === "load"
|
||||
var unwrap, response
|
||||
var unwrap
|
||||
|
||||
if (doSuccess) {
|
||||
unwrap = options.unwrapSuccess
|
||||
|
|
@ -2124,7 +2124,7 @@ void (function (global, factory) { // eslint-disable-line
|
|||
}
|
||||
|
||||
try {
|
||||
response = (unwrap || identity)(
|
||||
var response = (unwrap || identity)(
|
||||
deserialize(extract(ev.target, options)), ev.target)
|
||||
if (doSuccess) {
|
||||
if (isArray(response) && options.type) {
|
||||
|
|
@ -2134,16 +2134,15 @@ void (function (global, factory) { // eslint-disable-line
|
|||
} else if (options.type) {
|
||||
response = new options.type(response)
|
||||
}
|
||||
deferred.resolve(response)
|
||||
} else {
|
||||
deferred.reject(response)
|
||||
}
|
||||
} catch (e) {
|
||||
m.deferred.onerror(e)
|
||||
response = e
|
||||
doSuccess = false
|
||||
deferred.reject(e)
|
||||
} finally {
|
||||
if (options.background !== true) m.endComputation()
|
||||
}
|
||||
|
||||
deferred[doSuccess ? "resolve" : "reject"](response)
|
||||
|
||||
if (options.background !== true) m.endComputation()
|
||||
}
|
||||
|
||||
ajax(options)
|
||||
|
|
|
|||
6
mithril.min.js
vendored
6
mithril.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -345,4 +345,40 @@ describe("m.request()", function () {
|
|||
expect(req()).to.eql({foo: "bar1"})
|
||||
})
|
||||
})
|
||||
|
||||
it("ends the computation when a SyntaxError is thrown from `options.extract`", function () { // eslint-disable-line max-len
|
||||
var root = mock.document.createElement("div")
|
||||
var viewSpy = sinon.spy(function () { return m("div") })
|
||||
var resolved = sinon.spy()
|
||||
var rejected = sinon.spy()
|
||||
|
||||
m.mount(root, {
|
||||
controller: function () {
|
||||
m.request({
|
||||
url: "/test",
|
||||
extract: function () {
|
||||
throw new SyntaxError()
|
||||
}
|
||||
}).then(resolved, rejected)
|
||||
},
|
||||
|
||||
view: viewSpy
|
||||
})
|
||||
|
||||
// For good measure
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
|
||||
expect(function () {
|
||||
resolve()
|
||||
}).to.throw()
|
||||
|
||||
expect(resolved).to.not.have.been.called
|
||||
expect(rejected).to.not.have.been.called
|
||||
|
||||
// The controller should throw, but the view should still render.
|
||||
expect(viewSpy).to.have.been.called
|
||||
|
||||
// For good measure
|
||||
mock.requestAnimationFrame.$resolve()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ describe("m.trust()", function () {
|
|||
m("td", "foo")
|
||||
])
|
||||
|
||||
expect(root.childNodes[2].tagName).to.equal("td")
|
||||
expect(root.childNodes[2].tagName).to.equal("TD")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue