}"
`)
})
+
+ // #7554
+ test('scopeId is correctly transform to scope attribute of transition-group ', () => {
+ expect(
+ compile(
+ `<transition-group tag="div" class="red"><span>hello</span></transition-group>`,
+ {
+ scopeId,
+ mode: 'module'
+ }
+ ).code
+ ).toMatchInlineSnapshot(`
+ "import { mergeProps as _mergeProps } from \\"vue\\"
+ import { ssrRenderAttrs as _ssrRenderAttrs } from \\"vue/server-renderer\\"
+
+ export function ssrRender(_ctx, _push, _parent, _attrs) {
+ _push(\`<div\${_ssrRenderAttrs(_mergeProps({ class: \\"red\\" }, _attrs))} data-v-xxxxxxx><span data-v-xxxxxxx>hello</span></div>\`)
+ }"
+ `)
+
+ // with dynamic tag
+ expect(
+ compile(
+ `<transition-group :tag="someTag" class="red"><span>hello</span></transition-group>`,
+ {
+ scopeId,
+ mode: 'module'
+ }
+ ).code
+ ).toMatchInlineSnapshot(`
+ "import { mergeProps as _mergeProps } from \\"vue\\"
+ import { ssrRenderAttrs as _ssrRenderAttrs } from \\"vue/server-renderer\\"
+
+ export function ssrRender(_ctx, _push, _parent, _attrs) {
+ _push(\`<\${
+ _ctx.someTag
+ }\${
+ _ssrRenderAttrs(_mergeProps({ class: \\"red\\" }, _attrs))
+ } data-v-xxxxxxx><span data-v-xxxxxxx>hello</span></\${
+ _ctx.someTag
+ }>\`)
+ }"
+ `)
+ })
})
interface WIPEntry {
tag: AttributeNode | DirectiveNode
propsExp: string | JSChildNode | null
+ scopeId: string | null
}
// phase 1: build props
}
wipMap.set(node, {
tag,
- propsExp
+ propsExp,
+ scopeId: context.scopeId || null
})
}
}
) {
const entry = wipMap.get(node)
if (entry) {
- const { tag, propsExp } = entry
+ const { tag, propsExp, scopeId } = entry
if (tag.type === NodeTypes.DIRECTIVE) {
// dynamic :tag
context.pushStringPart(`<`)
if (propsExp) {
context.pushStringPart(propsExp)
}
+ if (scopeId) {
+ context.pushStringPart(` ${scopeId}`)
+ }
context.pushStringPart(`>`)
processChildren(
if (propsExp) {
context.pushStringPart(propsExp)
}
+ if (scopeId) {
+ context.pushStringPart(` ${scopeId}`)
+ }
context.pushStringPart(`>`)
processChildren(node, context, false, true)
context.pushStringPart(`</${tag.value!.content}>`)