Skip to content

Commit 2a13148

Browse files
committed
fix(TransitionGroup): 使用 hasOwn 函数优化属性过滤逻辑
- 在 TransitionGroup 中引入 hasOwn 函数,替代原有的属性检查方式 - 确保仅有效的 HTML 属性被传递到渲染的元素中,进一步避免无效的 HTML 属性问题
1 parent f32d148 commit 2a13148

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/runtime-dom/src/components/TransitionGroup.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
useTransitionState,
2828
warn,
2929
} from '@vue/runtime-core'
30-
import { extend } from '@vue/shared'
30+
import { extend, hasOwn } from '@vue/shared'
3131

3232
const positionMap = new WeakMap<VNode, DOMRect>()
3333
const newPositionMap = new WeakMap<VNode, DOMRect>()
@@ -135,7 +135,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
135135
const filteredProps: Record<string, any> = {}
136136
for (const key in rawProps) {
137137
if (
138-
!(key in TransitionPropsValidators) &&
138+
!hasOwn(TransitionPropsValidators, key) &&
139139
key !== 'tag' &&
140140
key !== 'moveClass'
141141
) {
@@ -179,8 +179,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
179179
warn(`<TransitionGroup> children must be keyed.`)
180180
}
181181
}
182-
183-
return createVNode(tag, filteredProps, children)
182+
return createVNode(tag, tag === Fragment ? null : filteredProps, children)
184183
}
185184
},
186185
})

0 commit comments

Comments
 (0)