Evan You 10 лет назад
Родитель
Сommit
fe48c6cf07
2 измененных файлов с 8 добавлено и 5 удалено
  1. 4 4
      src/entries/web-compiler.js
  2. 4 1
      src/server/create-renderer.js

+ 4 - 4
src/entries/web-compiler.js

@@ -10,6 +10,7 @@ const cache2 = Object.create(null)
 
 const baseOptions = {
   expectHTML: true,
+  preserveWhitespace: true,
   directives,
   isReservedTag,
   isUnaryTag,
@@ -19,7 +20,7 @@ const baseOptions = {
 
 export function compile (
   template: string,
-  options: Object
+  options: ?Object
 ): { render: string, staticRenderFns: Array<string> } {
   options = options
     ? extend(extend({}, baseOptions), options)
@@ -31,15 +32,14 @@ export function compileToFunctions (
   template: string,
   options: Object = {}
 ): { render: Function, staticRenderFns: Array<Function> } {
-  options.preserveWhitespace = options.preserveWhitespace !== false
-  const cache = options.preserveWhitespace ? cache1 : cache2
+  const cache = options.preserveWhitespace !== false ? cache1 : cache2
   if (cache[template]) {
     return cache[template]
   }
   const res = {}
   const compiled = compile(template, options)
   res.render = new Function(compiled.render)
-  const l: number = compiled.staticRenderFns.length
+  const l = compiled.staticRenderFns.length
   res.staticRenderFns = new Array(l)
   for (let i = 0; i < l; i++) {
     res.staticRenderFns[i] = new Function(compiled.staticRenderFns[i])

+ 4 - 1
src/server/create-renderer.js

@@ -28,7 +28,10 @@ export function createRenderer ({
   const render = createRenderFunction(modules, directives, isUnaryTag)
 
   return {
-    renderToString (component: Vue, done: Function): void {
+    renderToString (
+      component: Vue,
+      done: (err: ?Error, res: ?string) => any
+    ): void {
       let result = ''
       let stackDepth = 0
       const write = (str: string, next: Function) => {