mirror of
https://gitee.com/vuejs/vue.git
synced 2024-12-04 04:57:40 +08:00
adjust renderToString context argument position
This commit is contained in:
parent
2d50ac177b
commit
67d02fbf3f
@ -89,10 +89,10 @@ export function createBundleRendererCreator (createRenderer: () => Renderer) {
|
||||
cb(err)
|
||||
}).then(app => {
|
||||
if (app) {
|
||||
renderer.renderToString(app, (err, res) => {
|
||||
renderer.renderToString(app, context, (err, res) => {
|
||||
rewriteErrorTrace(err, maps)
|
||||
cb(err, res)
|
||||
}, context)
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
@ -7,8 +7,8 @@ import { createRenderFunction } from './render'
|
||||
import type { ClientManifest } from './template-renderer/index'
|
||||
|
||||
export type Renderer = {
|
||||
renderToString: (component: Component, cb: (err: ?Error, res: ?string) => void) => void;
|
||||
renderToStream: (component: Component) => stream$Readable;
|
||||
renderToString: (component: Component, context: any, cb: any) => void;
|
||||
renderToStream: (component: Component, context?: Object) => stream$Readable;
|
||||
};
|
||||
|
||||
type RenderCache = {
|
||||
@ -51,9 +51,13 @@ export function createRenderer ({
|
||||
return {
|
||||
renderToString (
|
||||
component: Component,
|
||||
done: (err: ?Error, res: ?string) => any,
|
||||
context?: ?Object
|
||||
context: any,
|
||||
done: any
|
||||
): void {
|
||||
if (typeof context === 'function') {
|
||||
done = context
|
||||
context = {}
|
||||
}
|
||||
if (context) {
|
||||
templateRenderer.bindRenderFns(context)
|
||||
}
|
||||
@ -76,7 +80,7 @@ export function createRenderer ({
|
||||
|
||||
renderToStream (
|
||||
component: Component,
|
||||
context?: ?Object
|
||||
context?: Object
|
||||
): stream$Readable {
|
||||
if (context) {
|
||||
templateRenderer.bindRenderFns(context)
|
||||
|
@ -54,7 +54,7 @@ describe('SSR: template option', () => {
|
||||
|
||||
renderer.renderToString(new Vue({
|
||||
template: '<div>hi</div>'
|
||||
}), (err, res) => {
|
||||
}), context, (err, res) => {
|
||||
expect(err).toBeNull()
|
||||
expect(res).toContain(
|
||||
`<html><head>${context.head}${context.styles}</head><body>` +
|
||||
@ -63,7 +63,7 @@ describe('SSR: template option', () => {
|
||||
`</body></html>`
|
||||
)
|
||||
done()
|
||||
}, context)
|
||||
})
|
||||
})
|
||||
|
||||
it('renderToString with interpolation', done => {
|
||||
@ -81,7 +81,7 @@ describe('SSR: template option', () => {
|
||||
|
||||
renderer.renderToString(new Vue({
|
||||
template: '<div>hi</div>'
|
||||
}), (err, res) => {
|
||||
}), context, (err, res) => {
|
||||
expect(err).toBeNull()
|
||||
expect(res).toContain(
|
||||
`<html><head>` +
|
||||
@ -95,7 +95,7 @@ describe('SSR: template option', () => {
|
||||
`</body></html>`
|
||||
)
|
||||
done()
|
||||
}, context)
|
||||
})
|
||||
})
|
||||
|
||||
it('renderToStream', done => {
|
||||
|
Loading…
Reference in New Issue
Block a user