Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(runtime-core): replace vnode.shapeFlag checks with existed functions #12406

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions packages/runtime-core/src/componentRenderUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
type Data,
type FunctionalComponent,
getComponentName,
isStatefulComponent,
} from './component'
import {
Comment,
Expand Down Expand Up @@ -50,7 +51,7 @@ export function renderComponentRoot(
vnode,
proxy,
withProxy,
propsOptions: [propsOptions],
propsOptions: [propsOption],
slots,
attrs,
emit,
Expand All @@ -63,6 +64,7 @@ export function renderComponentRoot(
inheritAttrs,
} = instance
const prev = setCurrentRenderingInstance(instance)
const isStateful = isStatefulComponent(instance)

let result
let fallthroughAttrs
Expand All @@ -71,7 +73,7 @@ export function renderComponentRoot(
}

try {
if (vnode.shapeFlag & ShapeFlags.STATEFUL_COMPONENT) {
if (isStateful) {
edison1105 marked this conversation as resolved.
Show resolved Hide resolved
// withProxy is a proxy with a different `has` trap only for
// runtime-compiled render functions using `with` block.
const proxyToUse = withProxy || proxy
Expand Down Expand Up @@ -154,18 +156,14 @@ 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 (propsOptions && keys.some(isModelListener)) {
if (isElementRoot(root)) {
edison1105 marked this conversation as resolved.
Show resolved Hide resolved
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) {
Expand Down Expand Up @@ -210,8 +208,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) {
Expand Down