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) {
1515 this . size = 0
1616 this . limit = limit
1717 this . head = this . tail = undefined
18- this . _keymap = { }
18+ this . _keymap = Object . create ( null )
1919}
2020
2121var p = Cache . prototype
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ var _ = require('../util')
22var compiler = require ( '../compiler' )
33var templateParser = require ( '../parsers/template' )
44var transition = require ( '../transition' )
5+ var Cache = require ( '../cache' )
6+ var cache = new Cache ( 1000 )
57
68module . exports = {
79
@@ -19,11 +21,16 @@ module.exports = {
1921 this . template . appendChild ( templateParser . clone ( el ) )
2022 }
2123 // 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+ }
2734 } else {
2835 process . env . NODE_ENV !== 'production' && _ . warn (
2936 'v-if="' + this . expression + '" cannot be ' +
You can’t perform that action at this time.
0 commit comments