|
|
@@ -2,6 +2,8 @@ var _ = require('../util')
|
|
|
var compiler = require('../compiler')
|
|
|
var templateParser = require('../parsers/template')
|
|
|
var transition = require('../transition')
|
|
|
+var Cache = require('../cache')
|
|
|
+var cache = new Cache(1000)
|
|
|
|
|
|
module.exports = {
|
|
|
|
|
|
@@ -19,11 +21,16 @@ module.exports = {
|
|
|
this.template.appendChild(templateParser.clone(el))
|
|
|
}
|
|
|
// compile the nested partial
|
|
|
- this.linker = compiler.compile(
|
|
|
- this.template,
|
|
|
- this.vm.$options,
|
|
|
- true
|
|
|
- )
|
|
|
+ var cacheId = (this.vm.constructor.cid || '') + el.outerHTML
|
|
|
+ this.linker = cache.get(cacheId)
|
|
|
+ if (!this.linker) {
|
|
|
+ this.linker = compiler.compile(
|
|
|
+ this.template,
|
|
|
+ this.vm.$options,
|
|
|
+ true
|
|
|
+ )
|
|
|
+ cache.put(cacheId, this.linker)
|
|
|
+ }
|
|
|
} else {
|
|
|
process.env.NODE_ENV !== 'production' && _.warn(
|
|
|
'v-if="' + this.expression + '" cannot be ' +
|