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

fix(TransitionGroup): not warn unkeyed text children with whitespece preserve #11888

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion packages/runtime-dom/src/components/TransitionGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
DeprecationTypes,
Fragment,
type SetupContext,
Text,
type VNode,
compatUtils,
createVNode,
Expand Down Expand Up @@ -159,7 +160,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
child,
resolveTransitionHooks(child, cssTransitionProps, state, instance),
)
} else if (__DEV__) {
} else if (__DEV__ && child.type !== Text) {
warn(`<TransitionGroup> children must be keyed.`)
}
}
Expand Down
15 changes: 15 additions & 0 deletions packages/vue/__tests__/e2e/TransitionGroup.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,21 @@ describe('e2e: TransitionGroup', () => {
expect(`<TransitionGroup> children must be keyed`).toHaveBeenWarned()
})

test('not warn unkeyed text children w/ whitespace preserve', () => {
const app = createApp({
template: `
<transition-group name="test">
<p key="1">1</p>
<p key="2" v-if="false">2</p>
</transition-group>
`,
})

app.config.compilerOptions.whitespace = 'preserve'
app.mount(document.createElement('div'))
expect(`<TransitionGroup> children must be keyed`).not.toHaveBeenWarned()
})

// #5168, #7898, #9067
test(
'avoid set transition hooks for comment node',
Expand Down