Browse Source

tweak annotations

dev
Evan You 9 years ago
parent
commit
df259d00f4
  1. 1
      flow/compiler.js
  2. 19
      src/entries/web-compiler.js

1
flow/compiler.js

@ -1,6 +1,7 @@
declare type CompilerOptions = {
warn?: Function,
expectHTML?: boolean,
preserveWhitespace?: boolean,
directives?: { [key: string]: Function },
isUnaryTag?: (tag: string) => ?boolean,
isReservedTag?: (tag: string) => ?boolean,

19
src/entries/web-compiler.js

@ -5,10 +5,15 @@ import { compile as baseCompile } from 'compiler/index'
import directives from 'web/compiler/directives/index'
import { isReservedTag, isUnaryTag, mustUseProp, getTagNamespace } from 'web/util/index'
const cache1 = Object.create(null)
const cache2 = Object.create(null)
type CompiledFunctions = {
render: Function,
staticRenderFns: Array<Function>
}
const cache1: { [key: string]: CompiledFunctions } = Object.create(null)
const cache2: { [key: string]: CompiledFunctions } = Object.create(null)
const baseOptions = {
const baseOptions: CompilerOptions = {
expectHTML: true,
preserveWhitespace: true,
directives,
@ -20,7 +25,7 @@ const baseOptions = {
export function compile (
template: string,
options: ?Object
options?: CompilerOptions
): { render: string, staticRenderFns: Array<string> } {
options = options
? extend(extend({}, baseOptions), options)
@ -30,9 +35,9 @@ export function compile (
export function compileToFunctions (
template: string,
options: Object = {}
): { render: Function, staticRenderFns: Array<Function> } {
const cache = options.preserveWhitespace !== false ? cache1 : cache2
options?: CompilerOptions
): CompiledFunctions {
const cache = options && options.preserveWhitespace === false ? cache1 : cache2
if (cache[template]) {
return cache[template]
}

Loading…
Cancel
Save