]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
fix(runtime-core): use correct parentNode when patching dynamicChildren (close #98)
authorEvan You <yyx990803@gmail.com>
Thu, 10 Oct 2019 18:49:35 +0000 (14:49 -0400)
committerEvan You <yyx990803@gmail.com>
Thu, 10 Oct 2019 18:49:35 +0000 (14:49 -0400)
packages/runtime-core/src/createRenderer.ts
packages/runtime-dom/src/nodeOps.ts

index 647a4ac9069be170f8c5ec55862d1499e1029c71..2c836071ba62063f8d1b8a89f639c9c53694a41d 100644 (file)
@@ -114,7 +114,7 @@ export interface RendererOptions<HostNode = any, HostElement = any> {
   createComment(text: string): HostNode
   setText(node: HostNode, text: string): void
   setElementText(node: HostElement, text: string): void
-  parentNode(node: HostNode): HostNode | null
+  parentNode(node: HostNode): HostElement | null
   nextSibling(node: HostNode): HostNode | null
   querySelector(selector: string): HostElement | null
 }
@@ -499,10 +499,11 @@ export function createRenderer<
       // children fast path
       const oldDynamicChildren = n1.dynamicChildren!
       for (let i = 0; i < dynamicChildren.length; i++) {
+        const oldVNode = oldDynamicChildren[i]
         patch(
-          oldDynamicChildren[i],
+          oldVNode,
           dynamicChildren[i],
-          el,
+          hostParentNode(oldVNode.el!)!,
           null,
           parentComponent,
           parentSuspense,
index e7b3e86b7a1ec28bf227945afdfd7033f7c44a97..7e6b6ed3ce06dce10fe671b7df2484ea428b5fdc 100644 (file)
@@ -4,7 +4,11 @@ const svgNS = 'http://www.w3.org/2000/svg'
 export const nodeOps = {
   insert: (child: Node, parent: Node, anchor?: Node) => {
     if (anchor != null) {
-      parent.insertBefore(child, anchor)
+      try {
+        parent.insertBefore(child, anchor)
+      } catch (e) {
+        debugger
+      }
     } else {
       parent.appendChild(child)
     }
@@ -32,7 +36,8 @@ export const nodeOps = {
     el.textContent = text
   },
 
-  parentNode: (node: Node): Node | null => node.parentNode,
+  parentNode: (node: Node): HTMLElement | null =>
+    node.parentNode as HTMLElement,
 
   nextSibling: (node: Node): Node | null => node.nextSibling,