Evan You 10 лет назад
Родитель
Сommit
959a95999a
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      src/compiler/parser/index.js

+ 4 - 2
src/compiler/parser/index.js

@@ -1,7 +1,7 @@
 import { decodeHTML } from 'entities'
 import { parseHTML } from './html-parser'
 import { parseText } from './text-parser'
-import { hyphenate, makeMap } from '../../shared/util'
+import { hyphenate, makeMap, cached } from '../../shared/util'
 import {
   getAndRemoveAttr,
   addProp,
@@ -21,6 +21,8 @@ const forAliasRE = /(.*)\s+(?:in|of)\s+(.*)/
 const forIteratorRE = /\((.*),(.*)\)/
 const camelRE = /[a-z\d][A-Z]/
 
+const decodeHTMLCached = cached(decodeHTML)
+
 // attributes that should be using props for binding
 const mustUseProp = makeMap('value,selected,checked,muted')
 
@@ -155,7 +157,7 @@ export function parse (template, options) {
         return
       }
       text = currentParent.tag === 'pre' || text.trim()
-        ? decodeHTML(text)
+        ? decodeHTMLCached(text)
         // only preserve whitespace if its not right after a starting tag
         : options.preserveWhitespace && currentParent.children.length
           ? ' '