Explorar o código

v-if linker should be host-sensitive (fix #1185)

Evan You %!s(int64=10) %!d(string=hai) anos
pai
achega
22ac9de4f5
Modificáronse 2 ficheiros con 8 adicións e 1 borrados
  1. 5 1
      src/directives/if.js
  2. 3 0
      src/instance/init.js

+ 5 - 1
src/directives/if.js

@@ -21,7 +21,11 @@ module.exports = {
         this.template.appendChild(templateParser.clone(el))
         this.template.appendChild(templateParser.clone(el))
       }
       }
       // compile the nested partial
       // compile the nested partial
-      var cacheId = (this.vm.constructor.cid || '') + el.outerHTML
+      var cacheId =
+        (this.vm.constructor.cid + '.' || '') +
+        // fix #1185: linker is host-sensitive
+        (this._host ? this._host._uid + '.' : '') +
+        el.outerHTML
       this.linker = cache.get(cacheId)
       this.linker = cache.get(cacheId)
       if (!this.linker) {
       if (!this.linker) {
         this.linker = compiler.compile(
         this.linker = compiler.compile(

+ 3 - 0
src/instance/init.js

@@ -1,4 +1,5 @@
 var mergeOptions = require('../util').mergeOptions
 var mergeOptions = require('../util').mergeOptions
+var uid = 0
 
 
 /**
 /**
  * The main init sequence. This is called for every
  * The main init sequence. This is called for every
@@ -25,6 +26,8 @@ exports._init = function (options) {
   this._directives = [] // all directives
   this._directives = [] // all directives
   this._childCtors = {} // inherit:true constructors
   this._childCtors = {} // inherit:true constructors
 
 
+  this._uid = uid++
+
   // a flag to avoid this being observed
   // a flag to avoid this being observed
   this._isVue = true
   this._isVue = true