Skip to content

Commit

Permalink
refactor: ssrPrefetch -> serverPrefetch for more consistent naming
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 18, 2019
1 parent df064ce commit 42fdf3f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/server/render.js
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -432,6 +432,6 @@ export function createRenderFunction (
const resolve = () => {
renderNode(component._render(), true, context)
}
waitForSsrPrefetch(component, resolve, done)
waitForServerPrefetch(component, resolve, done)
}
}
2 changes: 1 addition & 1 deletion src/shared/constants.js
Expand Up @@ -18,5 +18,5 @@ export const LIFECYCLE_HOOKS = [
'activated',
'deactivated',
'errorCaptured',
'ssrPrefetch'
'serverPrefetch'
]
26 changes: 13 additions & 13 deletions test/ssr/ssr-string.spec.js
Expand Up @@ -1312,15 +1312,15 @@ describe('SSR: renderToString', () => {
})
})

it('should support ssrPrefetch option', done => {
it('should support serverPrefetch option', done => {
renderVmWithOptions({
template: `
<div>{{ count }}</div>
`,
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.count = 42
Expand All @@ -1334,7 +1334,7 @@ describe('SSR: renderToString', () => {
})
})

it('should support ssrPrefetch option (nested)', done => {
it('should support serverPrefetch option (nested)', done => {
renderVmWithOptions({
template: `
<div>
Expand All @@ -1345,7 +1345,7 @@ describe('SSR: renderToString', () => {
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.count = 42
Expand All @@ -1363,7 +1363,7 @@ describe('SSR: renderToString', () => {
message: ''
}
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.message = 'vue.js'
Expand All @@ -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>
Expand All @@ -1390,7 +1390,7 @@ describe('SSR: renderToString', () => {
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.count = 42
Expand All @@ -1409,7 +1409,7 @@ describe('SSR: renderToString', () => {
message: ''
}
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.message = 'vue.js'
Expand All @@ -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'
Expand All @@ -1451,7 +1451,7 @@ describe('SSR: renderToString', () => {
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
return new Promise((resolve) => {
setTimeout(() => {
this.count = 42
Expand All @@ -1465,15 +1465,15 @@ 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>
`,
data: {
count: 0
},
ssrPrefetch () {
serverPrefetch () {
setTimeout(() => {
this.count = 42
}, 1)
Expand Down
4 changes: 2 additions & 2 deletions types/options.d.ts
Expand Up @@ -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>
Expand Down Expand Up @@ -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> };
Expand Down
2 changes: 1 addition & 1 deletion types/test/options-test.ts
Expand Up @@ -241,7 +241,7 @@ Vue.component('component', {
info.toUpperCase()
return true
},
ssrPrefetch () {
serverPrefetch () {
return Promise.resolve()
},

Expand Down

0 comments on commit 42fdf3f

Please sign in to comment.