Test case for circular component returns

This commit is contained in:
Barney Carroll 2016-08-22 11:37:42 +01:00
parent db45260dbc
commit f2f8bf825e

View file

@ -254,6 +254,22 @@ o.spec("component", function() {
o(root.childNodes.length).equals(0)
})
o("throws a custom error if it returns itself", function() {
// A view that returns its vnode would otherwise trigger an infinite loop
var component = {
view: function(vnode) {
return vnode
}
}
try {
render(root, [{tag: component}])
}
catch(error){
o(error instanceof Error).equals(true)
// Call stack excession is a RangeError
o(error instanceof RangeError).equals(false)
}
})
o("can update when returning fragments", function() {
var component = {
view: function(vnode) {