Skip to content

Commit

Permalink
fix(compiler-ssr/teleport): correct the target prop of teleport (#2053)
Browse files Browse the repository at this point in the history
  • Loading branch information
HcySunYang authored Sep 15, 2020
1 parent cdd849a commit 7455dca
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions packages/compiler-ssr/__tests__/ssrPortal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { compile } from '../src'

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

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

expect(
compile(`<teleport :target="target" :disabled="foo"><div/></teleport>`)
.code
compile(`<teleport :to="target" :disabled="foo"><div/></teleport>`).code
).toMatchInlineSnapshot(`
"const { ssrRenderTeleport: _ssrRenderTeleport } = require(\\"@vue/server-renderer\\")
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-ssr/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ export const enum SSRErrorCodes {
export const SSRErrorMessages: { [code: number]: string } = {
[SSRErrorCodes.X_SSR_CUSTOM_DIRECTIVE_NO_TRANSFORM]: `Custom directive is missing corresponding SSR transform and will be ignored.`,
[SSRErrorCodes.X_SSR_UNSAFE_ATTR_NAME]: `Unsafe attribute name for SSR.`,
[SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `No target prop on teleport element.`,
[SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET]: `Missing the 'to' prop on teleport element.`,
[SSRErrorCodes.X_SSR_INVALID_AST_NODE]: `Invalid AST node during SSR transform.`
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function ssrProcessTeleport(
node: ComponentNode,
context: SSRTransformContext
) {
const targetProp = findProp(node, 'target')
const targetProp = findProp(node, 'to')
if (!targetProp) {
context.onError(
createSSRCompilerError(SSRErrorCodes.X_SSR_NO_TELEPORT_TARGET, node.loc)
Expand Down

0 comments on commit 7455dca

Please sign in to comment.