]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip(vapor): optimize vapor interop update
authorEvan You <evan@vuejs.org>
Tue, 4 Feb 2025 05:11:51 +0000 (13:11 +0800)
committerEvan You <evan@vuejs.org>
Tue, 4 Feb 2025 05:11:51 +0000 (13:11 +0800)
packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/renderer.ts
packages/runtime-vapor/src/vdomInterop.ts

index 8083e9d1983b59028d5352137103c06e59fd8eff..a81c6b433b3c45b7f01179ad51e10e20238650b5 100644 (file)
@@ -189,7 +189,7 @@ export interface VaporInVDOMInterface {
     anchor: any,
     parentComponent: ComponentInternalInstance | null,
   ): GenericComponentInstance // VaporComponentInstance
-  update(n1: VNode, n2: VNode): void
+  update(n1: VNode, n2: VNode, shouldUpdate: boolean): void
   unmount(vnode: VNode, doRemove?: boolean): void
   move(vnode: VNode, container: any, anchor: any): void
 }
index 182d8a99a76f9c2cc1fda3c512a4835d185ddfc0..0a745a90b85e4293dc09bdfac6f1c00a0deeb406 100644 (file)
@@ -1158,7 +1158,11 @@ function baseCreateRenderer(
           parentComponent,
         )
       } else {
-        getVaporInterface(parentComponent).update(n1, n2)
+        getVaporInterface(parentComponent).update(
+          n1,
+          n2,
+          shouldUpdateComponent(n1, n2, optimized),
+        )
       }
     } else if (n1 == null) {
       if (n2.shapeFlag & ShapeFlags.COMPONENT_KEPT_ALIVE) {
index a515c853d61605a58b28dae84d067f0cfcac7ac7..aed0365cf41c6b385ee7cc13c3547fb92cabf93f 100644 (file)
@@ -1,7 +1,5 @@
 import {
-  type GenericComponentInstance,
   type Plugin,
-  type VNode,
   type VaporInVDOMInterface,
   currentInstance,
   shallowRef,
@@ -16,12 +14,7 @@ import {
 import { insert } from './block'
 
 const vaporInVDOMInterface: VaporInVDOMInterface = {
-  mount(
-    vnode: VNode,
-    container: ParentNode,
-    anchor: Node,
-    parentComponent: GenericComponentInstance | null,
-  ) {
+  mount(vnode, container, anchor, parentComponent) {
     const selfAnchor = (vnode.anchor = document.createComment('vapor'))
     container.insertBefore(selfAnchor, anchor)
     const prev = currentInstance
@@ -37,19 +30,20 @@ const vaporInVDOMInterface: VaporInVDOMInterface = {
     return instance
   },
 
-  update(n1: VNode, n2: VNode) {
+  update(n1, n2, shouldUpdate) {
     n2.component = n1.component
-    // TODO if has patchFlag, do simple diff to skip unnecessary updates
-    ;(n2.component as any as VaporComponentInstance).rawPropsRef!.value =
-      n2.props
+    if (shouldUpdate) {
+      ;(n2.component as any as VaporComponentInstance).rawPropsRef!.value =
+        n2.props
+    }
   },
 
-  unmount(vnode: VNode, doRemove?: boolean) {
+  unmount(vnode, doRemove) {
     const container = doRemove ? vnode.anchor!.parentNode : undefined
     unmountComponent(vnode.component as any, container)
   },
 
-  move(vnode: VNode, container: ParentNode, anchor: Node) {
+  move(vnode, container, anchor) {
     insert(vnode.component as any, container, anchor)
     insert(vnode.anchor as any, container, anchor)
   },