|
|
@@ -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])
|