Error when inserting node during render: "Failed to execute 'insertBefore' on 'Node'" #2128
When rendering there should be no errors and all the elements should be rendered in the correct order.
When inserting a node during the render process, if
This happens in the following situations that I have found. In all cases
Those are the only cases where
This commit: 02aab65 removed the check for
In the first case above the old element
updateNode(parent, o, v, hooks, getNextSibling(old, oldEnd + 1, nextSibling), ns) nextSibling = v.dom
function getNextSibling(vnodes, i, for (; i < vnodes.length; if (vnodes[i] != null && vnodes[i].dom != null && vnodes[i].dom.parentNode != null) return vnodes[i].dom } return nextSibling }
And for the second case the created fragment is set to
createNode(parent, v, hooks, ns, nextSibling) nextSibling = v.dom
I did some testing with the above changes and it appears to fix the error successfully and keep the correct order of elements. But I'm not too familiar with the code so I'm looking for some feedback.
I'd be happy to create the PR with these fixes if they're correct.
Steps to Reproduce (for bugs)
Simple steps to reproduce the first case:
Code snippet: Flems
The text was updated successfully, but these errors were encountered:
For 1) I think that we could set the DOM to
I'm almost certain that 2) is a bug in its own right and that
Thanks for the feedback.
Looks like changing
I tried the changes and some of the tests fail, including this one:
The fragment children are rendering out of order. Code snippet of the test.