From 42fdf3f8378e5dc379808a4fa67b39c4a74ae191 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 18 Jan 2019 16:43:17 -0500 Subject: [PATCH] refactor: ssrPrefetch -> serverPrefetch for more consistent naming --- src/server/render.js | 8 ++++---- src/shared/constants.js | 2 +- test/ssr/ssr-string.spec.js | 26 +++++++++++++------------- types/options.d.ts | 4 ++-- types/test/options-test.ts | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/server/render.js b/src/server/render.js index 4552bea839..05ba588006 100644 --- a/src/server/render.js +++ b/src/server/render.js @@ -50,8 +50,8 @@ const normalizeRender = vm => { } } -function waitForSsrPrefetch (vm, resolve, reject) { - let handlers = vm.$options.ssrPrefetch +function waitForServerPrefetch (vm, resolve, reject) { + let handlers = vm.$options.serverPrefetch if (isDef(handlers)) { if (!Array.isArray(handlers)) handlers = [handlers] try { @@ -206,7 +206,7 @@ function renderComponentInner (node, isRoot, context) { const reject = context.done - waitForSsrPrefetch(child, resolve, reject) + waitForServerPrefetch(child, resolve, reject) } function renderAsyncComponent (node, isRoot, context) { @@ -432,6 +432,6 @@ export function createRenderFunction ( const resolve = () => { renderNode(component._render(), true, context) } - waitForSsrPrefetch(component, resolve, done) + waitForServerPrefetch(component, resolve, done) } } diff --git a/src/shared/constants.js b/src/shared/constants.js index 018d657b66..a8b15e043d 100644 --- a/src/shared/constants.js +++ b/src/shared/constants.js @@ -18,5 +18,5 @@ export const LIFECYCLE_HOOKS = [ 'activated', 'deactivated', 'errorCaptured', - 'ssrPrefetch' + 'serverPrefetch' ] diff --git a/test/ssr/ssr-string.spec.js b/test/ssr/ssr-string.spec.js index 975197b6c1..66acf008a0 100644 --- a/test/ssr/ssr-string.spec.js +++ b/test/ssr/ssr-string.spec.js @@ -1312,7 +1312,7 @@ describe('SSR: renderToString', () => { }) }) - it('should support ssrPrefetch option', done => { + it('should support serverPrefetch option', done => { renderVmWithOptions({ template: `
{{ count }}
@@ -1320,7 +1320,7 @@ describe('SSR: renderToString', () => { data: { count: 0 }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.count = 42 @@ -1334,7 +1334,7 @@ describe('SSR: renderToString', () => { }) }) - it('should support ssrPrefetch option (nested)', done => { + it('should support serverPrefetch option (nested)', done => { renderVmWithOptions({ template: `
@@ -1345,7 +1345,7 @@ describe('SSR: renderToString', () => { data: { count: 0 }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.count = 42 @@ -1363,7 +1363,7 @@ describe('SSR: renderToString', () => { message: '' } }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.message = 'vue.js' @@ -1379,7 +1379,7 @@ describe('SSR: renderToString', () => { }) }) - it('should support ssrPrefetch option (nested async)', done => { + it('should support serverPrefetch option (nested async)', done => { renderVmWithOptions({ template: `
@@ -1390,7 +1390,7 @@ describe('SSR: renderToString', () => { data: { count: 0 }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.count = 42 @@ -1409,7 +1409,7 @@ describe('SSR: renderToString', () => { message: '' } }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.message = 'vue.js' @@ -1426,12 +1426,12 @@ describe('SSR: renderToString', () => { }) }) - it('should merge ssrPrefetch option', done => { + it('should merge serverPrefetch option', done => { const mixin = { data: { message: '' }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.message = 'vue.js' @@ -1451,7 +1451,7 @@ describe('SSR: renderToString', () => { data: { count: 0 }, - ssrPrefetch () { + serverPrefetch () { return new Promise((resolve) => { setTimeout(() => { this.count = 42 @@ -1465,7 +1465,7 @@ describe('SSR: renderToString', () => { }) }) - it(`should skip ssrPrefetch option that doesn't return a promise`, done => { + it(`should skip serverPrefetch option that doesn't return a promise`, done => { renderVmWithOptions({ template: `
{{ count }}
@@ -1473,7 +1473,7 @@ describe('SSR: renderToString', () => { data: { count: 0 }, - ssrPrefetch () { + serverPrefetch () { setTimeout(() => { this.count = 42 }, 1) diff --git a/types/options.d.ts b/types/options.d.ts index 08782da550..1bb5fbb619 100644 --- a/types/options.d.ts +++ b/types/options.d.ts @@ -15,7 +15,7 @@ export type Component, Methods=DefaultMethods, Co interface EsModuleComponent { default: Component } - + export type AsyncComponent, Methods=DefaultMethods, Computed=DefaultComputed, Props=DefaultProps> = AsyncComponentPromise | AsyncComponentFactory @@ -96,7 +96,7 @@ export interface ComponentOptions< activated?(): void; deactivated?(): void; errorCaptured?(err: Error, vm: Vue, info: string): boolean | void; - ssrPrefetch?(this: V): Promise; + serverPrefetch?(this: V): Promise; directives?: { [key: string]: DirectiveFunction | DirectiveOptions }; components?: { [key: string]: Component | AsyncComponent }; diff --git a/types/test/options-test.ts b/types/test/options-test.ts index 6fadd88fda..166d880610 100644 --- a/types/test/options-test.ts +++ b/types/test/options-test.ts @@ -241,7 +241,7 @@ Vue.component('component', { info.toUpperCase() return true }, - ssrPrefetch () { + serverPrefetch () { return Promise.resolve() },