Throw self-returning component to avoid infinite loop #1260

This commit is contained in:
Barney Carroll 2016-08-22 11:27:42 +01:00
parent 435b729289
commit db45260dbc

View file

@ -98,6 +98,8 @@ module.exports = function($window) {
initLifecycle(vnode.tag, vnode, hooks)
vnode.instance = Vnode.normalize(vnode.tag.view.call(vnode.state, vnode))
if (vnode.instance != null) {
if(vnode.instance === vnode)
throw Error("A component view mustn't return the vnode that was supplied to it.")
var element = createNode(vnode.instance, hooks, ns)
vnode.dom = vnode.instance.dom
vnode.domSize = vnode.dom != null ? vnode.instance.domSize : 0
@ -117,7 +119,7 @@ module.exports = function($window) {
else {
var recycling = isRecyclable(old, vnodes)
if (recycling) old = old.concat(old.pool)
if (old.length === vnodes.length && vnodes[0] != null && vnodes[0].key == null) {
for (var i = 0; i < old.length; i++) {
if (old[i] === vnodes[i] || old[i] == null && vnodes[i] == null) continue
@ -516,7 +518,7 @@ module.exports = function($window) {
function render(dom, vnodes) {
var hooks = []
var active = $doc.activeElement
// First time rendering into a node clears it out
if (dom.vnodes == null) dom.textContent = ""