Skip to content

Commit ad8d0be

Browse files
gucovipsxzz
authored andcommitted
fix(runtime-core): should not fallthrough attrs if attr declared in root component as prop
1 parent 61c3c8e commit ad8d0be

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/runtime-core/src/componentRenderUtils.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
ComponentInternalInstance,
33
FunctionalComponent,
44
Data,
5-
getComponentName
5+
getComponentName,
6+
ConcreteComponent
67
} from './component'
78
import {
89
VNode,
@@ -133,8 +134,18 @@ export function renderComponentRoot(
133134
}
134135

135136
if (fallthroughAttrs && inheritAttrs !== false) {
137+
const { shapeFlag, type, props } = root
138+
139+
if (shapeFlag & ShapeFlags.COMPONENT && props) {
140+
Object.keys(fallthroughAttrs).forEach(key => {
141+
if (key in props) {
142+
const propsDef = (type as ConcreteComponent).props
143+
if (propsDef && key in propsDef) delete fallthroughAttrs![key]
144+
}
145+
})
146+
}
147+
136148
const keys = Object.keys(fallthroughAttrs)
137-
const { shapeFlag } = root
138149
if (keys.length) {
139150
if (shapeFlag & (ShapeFlags.ELEMENT | ShapeFlags.COMPONENT)) {
140151
if (propsOptions && keys.some(isModelListener)) {

0 commit comments

Comments
 (0)