File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ function Compiler (vm, options) {
6363 // set compiler properties
6464 compiler . vm = el . vue_vm = vm
6565 compiler . bindings = makeHash ( )
66+ compiler . expCache = compiler . expCache || makeHash ( )
6667 compiler . dirs = [ ]
6768 compiler . deferred = [ ]
6869 compiler . computed = [ ]
@@ -677,7 +678,11 @@ CompilerProto.defineMeta = function (key, binding) {
677678 */
678679CompilerProto . defineExp = function ( key , binding , directive ) {
679680 var filters = directive && directive . computeFilters && directive . filters ,
680- getter = ExpParser . parse ( key , this , null , filters )
681+ exp = filters ? directive . expression : key ,
682+ getter = this . expCache [ exp ]
683+ if ( ! getter ) {
684+ getter = this . expCache [ exp ] = ExpParser . parse ( key , this , null , filters )
685+ }
681686 if ( getter ) {
682687 this . markComputed ( binding , getter )
683688 }
Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ module.exports = {
77
88 this . identifier = '$r' + this . id
99
10+ // a hash to cache the same expressions on repeated instances
11+ // so they don't have to be compiled for every single instance
12+ this . expCache = utils . hash ( )
13+
1014 var el = this . el ,
1115 ctn = this . container = el . parentNode
1216
@@ -64,7 +68,8 @@ module.exports = {
6468 el : el ,
6569 parent : this . vm ,
6670 compilerOptions : {
67- repeat : true
71+ repeat : true ,
72+ expCache : this . expCache
6873 }
6974 } ) . $destroy ( )
7075 this . initiated = true
@@ -210,7 +215,8 @@ module.exports = {
210215 data : data ,
211216 parent : this . vm ,
212217 compilerOptions : {
213- repeat : true
218+ repeat : true ,
219+ expCache : this . expCache
214220 }
215221 } )
216222
You can’t perform that action at this time.
0 commit comments