-
-
Notifications
You must be signed in to change notification settings - Fork 8.9k
fix(ssr): filter out transition-specific props to avoid invalid HTML attributes #13894
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
base: main
Are you sure you want to change the base?
Changes from 5 commits
f32d148
92e31b0
2a13148
ba3ac8a
d65747a
ca7407e
81615a2
a324b4e
a64f7f3
9f665ff
bf98abe
5590203
2a477e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,7 +32,17 @@ export function ssrTransformTransitionGroup( | |
| return (): void => { | ||
| const tag = findProp(node, 'tag') | ||
| if (tag) { | ||
| const otherProps = node.props.filter(p => p !== tag) | ||
| // 在处理 TransitionGroup 的属性时,过滤掉 name/tag 等私有 props | ||
| const otherProps = node.props.filter(p => { | ||
| // 排除 tag(已单独处理)和 name(私有 props,不该透传) | ||
| if ( | ||
| p === tag || | ||
| (p.type === NodeTypes.ATTRIBUTE && p.name === 'name') | ||
|
||
| ) { | ||
| return false | ||
| } | ||
| return true | ||
| }) | ||
| const { props, directives } = buildProps( | ||
| node, | ||
| context, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ import { | |
| useTransitionState, | ||
| warn, | ||
| } from '@vue/runtime-core' | ||
| import { extend } from '@vue/shared' | ||
| import { extend, hasOwn } from '@vue/shared' | ||
|
|
||
| const positionMap = new WeakMap<VNode, DOMRect>() | ||
| const newPositionMap = new WeakMap<VNode, DOMRect>() | ||
|
|
@@ -130,6 +130,19 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({ | |
| tag = 'span' | ||
| } | ||
|
|
||
| // Filter out transition-specific props and TransitionGroup-specific props | ||
| // to avoid invalid HTML attributes | ||
| const filteredProps: Record<string, any> = {} | ||
| for (const key in rawProps) { | ||
| if ( | ||
| !hasOwn(TransitionPropsValidators, key) && | ||
| key !== 'tag' && | ||
| key !== 'moveClass' | ||
| ) { | ||
| filteredProps[key] = (rawProps as any)[key] | ||
| } | ||
| } | ||
|
|
||
| prevChildren = [] | ||
| if (children) { | ||
| for (let i = 0; i < children.length; i++) { | ||
|
|
@@ -166,8 +179,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({ | |
| warn(`<TransitionGroup> children must be keyed.`) | ||
| } | ||
| } | ||
|
|
||
| return createVNode(tag, null, children) | ||
| return createVNode(tag, tag === Fragment ? null : filteredProps, children) | ||
|
||
| } | ||
| }, | ||
| }) | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
中文注释不太好,其他贡献者可能看不懂。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry 这边发现还有其他属性没有处理

我需要晚上回家处理下。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
谢谢您的督促,已经调整好了。