#1311 don't repeatedly throw the same error if oninit async-redraws and view throws
This commit is contained in:
parent
36ef994510
commit
3c6e257a19
4 changed files with 68 additions and 35 deletions
|
|
@ -95,8 +95,12 @@ module.exports = function($window) {
|
|||
if (!vnode.state) vnode.state = {}
|
||||
assign(vnode.state, vnode.tag)
|
||||
|
||||
var view = vnode.tag.view
|
||||
if (view.reentrantLock != null) return $emptyFragment
|
||||
view.reentrantLock = true
|
||||
initLifecycle(vnode.tag, vnode, hooks)
|
||||
vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
|
||||
vnode.instance = Vnode.normalize(view.call(vnode.state, vnode))
|
||||
view.reentrantLock = null
|
||||
if (vnode.instance != null) {
|
||||
if (vnode.instance === vnode) throw Error("A view cannot return the vnode it received as arguments")
|
||||
var element = createNode(vnode.instance, hooks, ns)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue