diff --git a/packages-private/vapor-e2e-test/interop/VaporComp.vue b/packages-private/vapor-e2e-test/interop/VaporComp.vue
index 88a60c782c0..f0156544919 100644
--- a/packages-private/vapor-e2e-test/interop/VaporComp.vue
+++ b/packages-private/vapor-e2e-test/interop/VaporComp.vue
@@ -27,7 +27,8 @@ const slotProp = ref('slot prop')
change slot prop
- #default:
+ #default:
+
#test:
fallback content
@@ -40,7 +41,7 @@ const slotProp = ref('slot prop')
>
Toggle default slot to vdom
-
+
slot prop: {{ foo }}
component prop: {{ msg }}
diff --git a/packages/compiler-core/src/index.ts b/packages/compiler-core/src/index.ts
index 36ed73eab92..e54b0c3a498 100644
--- a/packages/compiler-core/src/index.ts
+++ b/packages/compiler-core/src/index.ts
@@ -17,6 +17,7 @@ export {
createTransformContext,
traverseNode,
createStructuralDirectiveTransform,
+ getSelfName,
type NodeTransform,
type StructuralDirectiveTransform,
type DirectiveTransform,
diff --git a/packages/compiler-core/src/transform.ts b/packages/compiler-core/src/transform.ts
index aeb96cc2b4a..7d35ec9f700 100644
--- a/packages/compiler-core/src/transform.ts
+++ b/packages/compiler-core/src/transform.ts
@@ -123,6 +123,11 @@ export interface TransformContext
filters?: Set
}
+export function getSelfName(filename: string): string | null {
+ const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/)
+ return nameMatch ? capitalize(camelize(nameMatch[1])) : null
+}
+
export function createTransformContext(
root: RootNode,
{
@@ -150,11 +155,10 @@ export function createTransformContext(
compatConfig,
}: TransformOptions,
): TransformContext {
- const nameMatch = filename.replace(/\?.*$/, '').match(/([^/\\]+)\.\w+$/)
const context: TransformContext = {
// options
filename,
- selfName: nameMatch && capitalize(camelize(nameMatch[1])),
+ selfName: getSelfName(filename),
prefixIdentifiers,
hoistStatic,
hmr,
diff --git a/packages/compiler-ssr/__tests__/ssrComponent.spec.ts b/packages/compiler-ssr/__tests__/ssrComponent.spec.ts
index 2fde4560ec4..fb2fff86574 100644
--- a/packages/compiler-ssr/__tests__/ssrComponent.spec.ts
+++ b/packages/compiler-ssr/__tests__/ssrComponent.spec.ts
@@ -39,6 +39,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent, _attrs) {
_ssrRenderVNode(_push, _createVNode(_resolveDynamicComponent("foo"), _mergeProps({ prop: "b" }, _attrs), null), _parent)
+ _push(\`\`)
}"
`)
@@ -49,6 +50,7 @@ describe('ssr: components', () => {
return function ssrRender(_ctx, _push, _parent, _attrs) {
_ssrRenderVNode(_push, _createVNode(_resolveDynamicComponent(_ctx.foo), _mergeProps({ prop: "b" }, _attrs), null), _parent)
+ _push(\`\`)
}"
`)
})
@@ -244,7 +246,8 @@ describe('ssr: components', () => {
_ssrRenderList(list, (i) => {
_push(\`\`)
})
- _push(\` \`)
+ _push(\`\`)
+ _push(\`\`)
} else {
_push(\`\`)
}
@@ -267,7 +270,8 @@ describe('ssr: components', () => {
_ssrRenderList(_ctx.list, (i) => {
_push(\`\`)
})
- _push(\`\`)
+ _push(\`\`)
+ _push(\`\`)
} else {
_push(\`\`)
}
@@ -361,6 +365,7 @@ describe('ssr: components', () => {
_push(\`\`)
if (false) {
_push(\`\`)
+ _push(\`\`)
} else {
_push(\`\`)
}
diff --git a/packages/compiler-ssr/__tests__/ssrElement.spec.ts b/packages/compiler-ssr/__tests__/ssrElement.spec.ts
index f1d509acfb0..d344405f3ed 100644
--- a/packages/compiler-ssr/__tests__/ssrElement.spec.ts
+++ b/packages/compiler-ssr/__tests__/ssrElement.spec.ts
@@ -396,4 +396,50 @@ describe('ssr: element', () => {
`)
})
})
+
+ describe('dynamic anchor', () => {
+ test('two consecutive components', () => {
+ expect(
+ getCompiledString(`
+
+ `),
+ ).toMatchInlineSnapshot(`
+ "\`\`)
+ _push(_ssrRenderComponent(_component_Comp1, null, null, _parent))
+ _push(\`\`)
+ _push(_ssrRenderComponent(_component_Comp2, null, null, _parent))
+ _push(\`
\`"
+ `)
+ })
+
+ test('multiple consecutive components', () => {
+ expect(
+ getCompiledString(`
+
+ `),
+ ).toMatchInlineSnapshot(`
+ "\`\`)
+ _push(_ssrRenderComponent(_component_Comp1, null, null, _parent))
+ _push(\`\`)
+ _push(_ssrRenderComponent(_component_Comp2, null, null, _parent))
+ _push(\`\`)
+ _push(_ssrRenderComponent(_component_Comp3, null, null, _parent))
+ _push(\`\`)
+ _push(_ssrRenderComponent(_component_Comp4, null, null, _parent))
+ _push(\`
\`"
+ `)
+ })
+ })
})
diff --git a/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts b/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts
index 7b3d1962c3e..712c09d0946 100644
--- a/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts
+++ b/packages/compiler-ssr/__tests__/ssrFallthroughAttrs.spec.ts
@@ -29,6 +29,7 @@ describe('ssr: attrs fallthrough', () => {
_push(\`\`)
if (true) {
_push(\`\`)
+ _push(\`\`)
} else {
_push(\`\`)
}
diff --git a/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts b/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts
index 9e70dac0bdc..0666e8949cc 100644
--- a/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts
+++ b/packages/compiler-ssr/__tests__/ssrInjectCssVars.spec.ts
@@ -70,6 +70,7 @@ describe('ssr: inject