Browse Source

refactor: ssrPrefetch -> serverPrefetch for more consistent naming

dev
Evan You 6 years ago
parent
commit
42fdf3f837
  1. 8
      src/server/render.js
  2. 2
      src/shared/constants.js
  3. 26
      test/ssr/ssr-string.spec.js
  4. 4
      types/options.d.ts
  5. 2
      types/test/options-test.ts

8
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)
}
}

2
src/shared/constants.js

@ -18,5 +18,5 @@ export const LIFECYCLE_HOOKS = [
'activated',
'deactivated',
'errorCaptured',
'ssrPrefetch'
'serverPrefetch'
]

26
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: `
<div>{{ count }}</div>
@ -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: `
<div>
@ -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: `
<div>
@ -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: `
<div>{{ count }}</div>
@ -1473,7 +1473,7 @@ describe('SSR: renderToString', () => {
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
setTimeout(() => {
this.count = 42
}, 1)

4
types/options.d.ts

@ -15,7 +15,7 @@ export type Component<Data=DefaultData<never>, Methods=DefaultMethods<never>, Co
interface EsModuleComponent {
default: Component
}
export type AsyncComponent<Data=DefaultData<never>, Methods=DefaultMethods<never>, Computed=DefaultComputed, Props=DefaultProps>
= AsyncComponentPromise<Data, Methods, Computed, Props>
| AsyncComponentFactory<Data, Methods, Computed, Props>
@ -96,7 +96,7 @@ export interface ComponentOptions<
activated?(): void;
deactivated?(): void;
errorCaptured?(err: Error, vm: Vue, info: string): boolean | void;
ssrPrefetch?(this: V): Promise<void>;
serverPrefetch?(this: V): Promise<void>;
directives?: { [key: string]: DirectiveFunction | DirectiveOptions };
components?: { [key: string]: Component<any, any, any, any> | AsyncComponent<any, any, any, any> };

2
types/test/options-test.ts

@ -241,7 +241,7 @@ Vue.component('component', {
info.toUpperCase()
return true
},
ssrPrefetch () {
serverPrefetch () {
return Promise.resolve()
},

Loading…
Cancel
Save