previous fix caused regressions in nuxt
@@ -1684,7 +1684,9 @@ describe('Suspense', () => {
expect(serializeInner(root)).toBe('<div>async</div>')
viewRef.value = 1
- await nextTick() //TypeError: Cannot read properties of null (reading 'parentNode'),This has been fixed
+ await nextTick()
+ // TypeError: Cannot read properties of null (reading 'parentNode')
+ // This has been fixed
expect(serializeInner(root)).toBe(`<div>sync</div>`)
})
@@ -428,8 +428,16 @@ export function updateHOCHostEl(
{ vnode, parent }: ComponentInternalInstance,
el: typeof vnode.el // HostNode
) {
- while (parent && parent.subTree === vnode) {
- ;(vnode = parent.vnode).el = el
- parent = parent.parent
+ while (parent) {
+ const root = parent.subTree
+ if (root.suspense && root.suspense.activeBranch === vnode) {
+ root.el = vnode.el
+ }
+ if (root === vnode) {
+ ;(vnode = parent.vnode).el = el
+ parent = parent.parent
+ } else {
+ break
}
@@ -1241,10 +1241,6 @@ function baseCreateRenderer(
if (!initialVNode.el) {
const placeholder = (instance.subTree = createVNode(Comment))
processCommentNode(null, placeholder, container!, anchor)
- // This noramlly gets setup by the following `setupRenderEffect`.
- // But the call is skipped in initial mounting of async element.
- // Thus, manually patching is required here or it will result in a crash during parent component update.
- initialVNode.el = placeholder.el
return