#1311 don't repeatedly throw the same error if oninit async-redraws and view throws

This commit is contained in:
Leo Horie 2016-11-02 14:56:17 -04:00
parent 36ef994510
commit 3c6e257a19
4 changed files with 68 additions and 35 deletions

View file

@ -21,7 +21,8 @@ o.spec("render", function() {
o(root.childNodes.length).equals(0)
})
o("throws on invalid root node", function(){
o("throws on invalid root node", function() {
var threw = false
try {
render(null, [])
@ -30,4 +31,28 @@ o.spec("render", function() {
}
o(threw).equals(true)
})
o("does not enter infinite loop when oninit triggers render and view throws", function(done) {
var A = {
oninit: init,
view: function() {throw new Error("error")}
}
function run() {
render(root, {tag: A})
}
function init() {
setTimeout(function() {
var threwInner = false
try {run()} catch (e) {threwInner = true}
o(threwInner).equals(false)
done()
}, 0)
}
var threwOuter = false
try {run()} catch (e) {threwOuter = true}
o(threwOuter).equals(true)
})
})