File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ function Cache (limit) {
15
15
this . size = 0
16
16
this . limit = limit
17
17
this . head = this . tail = undefined
18
- this . _keymap = { }
18
+ this . _keymap = Object . create ( null )
19
19
}
20
20
21
21
var p = Cache . prototype
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ var _ = require('../util')
2
2
var compiler = require ( '../compiler' )
3
3
var templateParser = require ( '../parsers/template' )
4
4
var transition = require ( '../transition' )
5
+ var Cache = require ( '../cache' )
6
+ var cache = new Cache ( 1000 )
5
7
6
8
module . exports = {
7
9
@@ -19,11 +21,16 @@ module.exports = {
19
21
this . template . appendChild ( templateParser . clone ( el ) )
20
22
}
21
23
// compile the nested partial
22
- this . linker = compiler . compile (
23
- this . template ,
24
- this . vm . $options ,
25
- true
26
- )
24
+ var cacheId = ( this . vm . constructor . cid || '' ) + el . outerHTML
25
+ this . linker = cache . get ( cacheId )
26
+ if ( ! this . linker ) {
27
+ this . linker = compiler . compile (
28
+ this . template ,
29
+ this . vm . $options ,
30
+ true
31
+ )
32
+ cache . put ( cacheId , this . linker )
33
+ }
27
34
} else {
28
35
process . env . NODE_ENV !== 'production' && _ . warn (
29
36
'v-if="' + this . expression + '" cannot be ' +
You can’t perform that action at this time.
0 commit comments