mirror of https://github.com/vuejs/core.git
fix(TransitionGroup): not warn unkeyed text children with whitespece preserve (#11888)
close #11885
This commit is contained in:
parent
8ea5d6d698
commit
7571f20bc3
|
@ -14,6 +14,7 @@ import {
|
||||||
DeprecationTypes,
|
DeprecationTypes,
|
||||||
Fragment,
|
Fragment,
|
||||||
type SetupContext,
|
type SetupContext,
|
||||||
|
Text,
|
||||||
type VNode,
|
type VNode,
|
||||||
compatUtils,
|
compatUtils,
|
||||||
createVNode,
|
createVNode,
|
||||||
|
@ -159,7 +160,7 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
|
||||||
child,
|
child,
|
||||||
resolveTransitionHooks(child, cssTransitionProps, state, instance),
|
resolveTransitionHooks(child, cssTransitionProps, state, instance),
|
||||||
)
|
)
|
||||||
} else if (__DEV__) {
|
} else if (__DEV__ && child.type !== Text) {
|
||||||
warn(`<TransitionGroup> children must be keyed.`)
|
warn(`<TransitionGroup> children must be keyed.`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -509,6 +509,21 @@ describe('e2e: TransitionGroup', () => {
|
||||||
expect(`<TransitionGroup> children must be keyed`).toHaveBeenWarned()
|
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
|
// #5168, #7898, #9067
|
||||||
test(
|
test(
|
||||||
'avoid set transition hooks for comment node',
|
'avoid set transition hooks for comment node',
|
||||||
|
|
Loading…
Reference in New Issue