This commit is contained in:
白雾三语 2025-05-05 20:41:49 +00:00 committed by GitHub
commit d49cd02ecd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 1 deletions

View File

@ -19,6 +19,7 @@ import {
} from '@vue/runtime-test'
import { withCtx } from '../src/componentRenderContext'
import { PatchFlags } from '@vue/shared'
import { TransitionGroup } from '@vue/runtime-dom'
describe('scopeId runtime support', () => {
test('should attach scopeId', () => {
@ -214,6 +215,41 @@ describe('scopeId runtime support', () => {
)
})
test(':slotted should work on transitionGroup', async () => {
const Child = {
__scopeId: 'child',
render(this: any) {
return h('div', renderSlot(this.$slots, 'default'))
},
}
const App = {
__scopeId: 'parent',
render: () => {
return h(
Child,
withCtx(() => {
return [
h(TransitionGroup, null, {
default: withCtx(() => [
h('div', { key: 'foo' }, ' I have a TransitionGroup '),
]),
}),
]
}),
)
},
}
const root = nodeOps.createElement('div')
render(h(App), root)
// slot content should have:
// - scopeId from parent
// - slotted scopeId (with `-s` postfix) from child (the tree owner)
expect(serializeInner(root)).toBe(
`<div child parent><div parent child-s> I have a TransitionGroup </div></div>`,
)
})
// #1988
test('should inherit scopeId through nested HOCs with inheritAttrs: false', () => {
const App = {

View File

@ -167,7 +167,9 @@ const TransitionGroupImpl: ComponentOptions = /*@__PURE__*/ decorate({
}
}
return createVNode(tag, null, children)
const node = createVNode(tag, null, children)
node.slotScopeIds = instance.vnode.slotScopeIds
return node
}
},
})