From a866b288b684502beb78efb32ea9878bec771600 Mon Sep 17 00:00:00 2001 From: NoTwoBoy <1244476905@qq.com> Date: Fri, 15 Nov 2024 18:33:47 +0800 Subject: [PATCH 1/2] refactor(runtime-core): replace vnode.shapeFlag checks with existed functions --- packages/runtime-core/src/componentRenderUtils.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index a1afae6201a..9df289b471c 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -3,6 +3,7 @@ import { type Data, type FunctionalComponent, getComponentName, + isStatefulComponent, } from './component' import { Comment, @@ -63,6 +64,7 @@ export function renderComponentRoot( inheritAttrs, } = instance const prev = setCurrentRenderingInstance(instance) + const isStateful = isStatefulComponent(instance) let result let fallthroughAttrs @@ -71,7 +73,7 @@ export function renderComponentRoot( } try { - if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) { + if (isStateful) { // withProxy is a proxy with a different `has` trap only for // runtime-compiled render functions using `with` block. const proxyToUse = withProxy || proxy @@ -154,9 +156,8 @@ export function renderComponentRoot( if (fallthroughAttrs && inheritAttrs !== false) { const keys = Object.keys(fallthroughAttrs) - const { shapeFlag } = root if (keys.length) { - if (shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.COMPONENT)) { + if (isElementRoot(root)) { if (propsOptions && keys.some(isModelListener)) { // If a v-model listener (onUpdate:xxx) has a corresponding declared // prop, it indicates this component expects to handle v-model and @@ -210,8 +211,8 @@ export function renderComponentRoot( if ( __COMPAT__ && isCompatEnabled(DeprecationTypes.INSTANCE_ATTRS_CLASS_STYLE, instance) && - vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT && - root.shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.COMPONENT) + isStateful && + isElementRoot(root) ) { const { class: cls, style } = vnode.props || {} if (cls || style) { From 3cc3dde90940c294a26cf1329cd1127bb13dfce6 Mon Sep 17 00:00:00 2001 From: NoTwoBoy <1244476905@qq.com> Date: Mon, 18 Nov 2024 13:56:00 +0800 Subject: [PATCH 2/2] chore: update --- packages/runtime-core/src/componentRenderUtils.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/packages/runtime-core/src/componentRenderUtils.ts b/packages/runtime-core/src/componentRenderUtils.ts index 9df289b471c..5cbe82b13d7 100644 --- a/packages/runtime-core/src/componentRenderUtils.ts +++ b/packages/runtime-core/src/componentRenderUtils.ts @@ -51,7 +51,7 @@ export function renderComponentRoot( vnode, proxy, withProxy, - propsOptions: [propsOptions], + propsOptions: [propsOption], slots, attrs, emit, @@ -158,15 +158,12 @@ export function renderComponentRoot( const keys = Object.keys(fallthroughAttrs) if (keys.length) { if (isElementRoot(root)) { - if (propsOptions && keys.some(isModelListener)) { + if (propsOption && keys.some(isModelListener)) { // If a v-model listener (onUpdate:xxx) has a corresponding declared // prop, it indicates this component expects to handle v-model and // it should not fallthrough. // related: #1543, #1643, #1989 - fallthroughAttrs = filterModelListeners( - fallthroughAttrs, - propsOptions, - ) + fallthroughAttrs = filterModelListeners(fallthroughAttrs, propsOption) } root = cloneVNode(root, fallthroughAttrs, false, true) } else if (__DEV__ && !accessedAttrs && root.type !== Comment) {