mirror of https://github.com/vuejs/core.git
wip(vapor): optimize vapor interop update
This commit is contained in:
parent
b20bcf1fb6
commit
f09e343962
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue