-
-
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
Open
ZKunZhang
wants to merge
13
commits into
vuejs:main
Choose a base branch
from
ZKunZhang:fix/transition-group-props-filtering
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f32d148
fix(TransitionGroup): filter out transition-specific props to avoid i…
ZKunZhang 92e31b0
Merge branch 'vuejs:main' into fix/transition-group-props-filtering
ZKunZhang 2a13148
fix(TransitionGroup): 使用 hasOwn 函数优化属性过滤逻辑
ZKunZhang ba3ac8a
Merge branch 'fix/transition-group-props-filtering' of https://github…
ZKunZhang d65747a
fix(TransitionGroup): filter private props to avoid invalid HTML attr…
ZKunZhang ca7407e
fix(compiler-ssr): filter out all transition-specific props in Transi…
ZKunZhang 81615a2
refactor: update comments to English (previously Chinese)
ZKunZhang a324b4e
refactor(TransitionGroup): improve props handling and filtering
ZKunZhang a64f7f3
refactor(TransitionGroup): from main branchprocess for TransitionGroup
ZKunZhang 9f665ff
fix(compiler-ssr): filter v-bind object props in TransitionGroup SSR …
ZKunZhang bf98abe
fix(compiler-ssr): runtime filter for v-bind object in TransitionGrou…
ZKunZhang 5590203
fix(compiler-ssr): runtime filter transition props in TransitionGroup…
ZKunZhang 2a477e8
fix(compiler-ssr): runtime filter transition props in TransitionGroup…
ZKunZhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm confused. This seems to change the props from
nulltofilteredProps. If the old value wasnullthen it doesn't seem this is where the spurious props were being applied originally. I'm not sure how passing extra props here would help.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.
So the fix isn't changing from null to filteredProps - it's changing
from passing all props (including invalid HTML attributes like
transition props) to passing only valid HTML attributes.
The condition tag === Fragment ? null : filteredProps means:
HTML props
This prevents invalid HTML attributes like name="fade" or
duration="300" from appearing on the DOM element.
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.
But the original code is this:
That isn't passing all props, it's passing
null. The new code passes more props, not fewer.I believe the changes to this file are incorrect and should be reverted.
Uh oh!
There was an error while loading. Please reload this page.
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.
Thank you for your guidance, and this line of code has awakened me to the issue — I've identified a fundamental flaw in my previous approach to fixing the issue. The core problem is that Vue's automatic fallthrough mechanism fails to properly handle the declared props of TransitionGroup, causing properties that should be filtered by the component to erroneously appear in the final HTML. The runtime fallthrough mechanism malfunctions, resulting in transition-related attributes (such as name="fade") being incorrectly rendered into the HTML. The same issue occurs in SSR environments, generating HTML with invalid attributes. Therefore, my previous method of manually filtering attributes within each component was incorrect.
There is a critical flaw in how TransitionGroup handles props:
delete t.props.modeis executed in the decorate functionhasOwn(options, camelKey)to determine which properties are declared propsThe correct architecture-level fix should be:
It's important to note that during SSR compilation, all attributes are directly compiled into the generated code. Since SSR is processed at compile time rather than runtime, the runtime fallthrough mechanism does not take effect during SSR compilation.
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.
I double-checked and realized I had indeed misidentified the root cause of the issue. This led me to fix a file that didn’t need fixing, but I have now reverted that change. 😣