Skip to content

Commit 7455dca

Browse files
authored
fix(compiler-ssr/teleport): correct the target prop of teleport (#2053)
1 parent cdd849a commit 7455dca

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

packages/compiler-ssr/__tests__/ssrPortal.spec.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { compile } from '../src'
22

33
describe('ssr compile: teleport', () => {
44
test('should work', () => {
5-
expect(compile(`<teleport :target="target"><div/></teleport>`).code)
5+
expect(compile(`<teleport :to="target"><div/></teleport>`).code)
66
.toMatchInlineSnapshot(`
77
"const { ssrRenderTeleport: _ssrRenderTeleport } = require(\\"@vue/server-renderer\\")
88
@@ -15,9 +15,8 @@ describe('ssr compile: teleport', () => {
1515
})
1616

1717
test('disabled prop handling', () => {
18-
expect(
19-
compile(`<teleport :target="target" disabled><div/></teleport>`).code
20-
).toMatchInlineSnapshot(`
18+
expect(compile(`<teleport :to="target" disabled><div/></teleport>`).code)
19+
.toMatchInlineSnapshot(`
2120
"const { ssrRenderTeleport: _ssrRenderTeleport } = require(\\"@vue/server-renderer\\")
2221
2322
return function ssrRender(_ctx, _push, _parent, _attrs) {
@@ -28,8 +27,7 @@ describe('ssr compile: teleport', () => {
2827
`)
2928

3029
expect(
31-
compile(`<teleport :target="target" :disabled="foo"><div/></teleport>`)
32-
.code
30+
compile(`<teleport :to="target" :disabled="foo"><div/></teleport>`).code
3331
).toMatchInlineSnapshot(`
3432
"const { ssrRenderTeleport: _ssrRenderTeleport } = require(\\"@vue/server-renderer\\")
3533

packages/compiler-ssr/src/errors.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export const enum SSRErrorCodes {
2626
export const SSRErrorMessages: { [code: number]: string } = {
2727
[SSRErrorCodes.X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM]: `Custom directive is missing corresponding SSR transform and will be ignored.`,
2828
[SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME]: `Unsafe attribute name for SSR.`,
29-
[SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `No target prop on teleport element.`,
29+
[SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `Missing the 'to' prop on teleport element.`,
3030
[SSRErrorCodes.X_SSR_INVALID_AST_NODE]: `Invalid AST node during SSR transform.`
3131
}

packages/compiler-ssr/src/transforms/ssrTransformTeleport.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function ssrProcessTeleport(
1919
node: ComponentNode,
2020
context: SSRTransformContext
2121
) {
22-
const targetProp = findProp(node, 'target')
22+
const targetProp = findProp(node, 'to')
2323
if (!targetProp) {
2424
context.onError(
2525
createSSRCompilerError(SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET, node.loc)

0 commit comments

Comments
 (0)