Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler-ssr/Teleport): correct the target prop of Teleport #2053

Merged
merged 1 commit into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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