Skip to content

Commit f85160e

Browse files
committed
transclusion host should be passed at link time,
not compile time. (fix vuejs#1185 properly)
1 parent dbb3fac commit f85160e

File tree

4 files changed

+7
-15
lines changed

4 files changed

+7
-15
lines changed

src/api/lifecycle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@ exports.$destroy = function (remove, deferCleanup) {
6464
*/
6565

6666
exports.$compile = function (el, host) {
67-
return compiler.compile(el, this.$options, true, host)(this, el)
67+
return compiler.compile(el, this.$options, true)(this, el, host)
6868
}

src/compiler/compile.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ var terminalDirectives = [
2727
* @param {Element|DocumentFragment} el
2828
* @param {Object} options
2929
* @param {Boolean} partial
30-
* @param {Vue} [host] - host vm of transcluded content
3130
* @return {Function}
3231
*/
3332

34-
exports.compile = function (el, options, partial, host) {
33+
exports.compile = function (el, options, partial) {
3534
// link function for the node itself.
3635
var nodeLinkFn = partial || !options._asComponent
3736
? compileNode(el, options)
@@ -51,10 +50,11 @@ exports.compile = function (el, options, partial, host) {
5150
*
5251
* @param {Vue} vm
5352
* @param {Element|DocumentFragment} el
53+
* @param {Vue} [host] - host vm of transcluded content
5454
* @return {Function|undefined}
5555
*/
5656

57-
return function compositeLinkFn (vm, el) {
57+
return function compositeLinkFn (vm, el, host) {
5858
// cache childNodes before linking parent, fix #657
5959
var childNodes = _.toArray(el.childNodes)
6060
// link

src/directives/if.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,13 @@ module.exports = {
2121
this.template.appendChild(templateParser.clone(el))
2222
}
2323
// compile the nested partial
24-
var cacheId =
25-
(this.vm.constructor.cid + '.' || '') +
26-
// fix #1185: linker is host-sensitive
27-
(this._host ? this._host._uid + '.' : '') +
28-
el.outerHTML
24+
var cacheId = (this.vm.constructor.cid || '') + el.outerHTML
2925
this.linker = cache.get(cacheId)
3026
if (!this.linker) {
3127
this.linker = compiler.compile(
3228
this.template,
3329
this.vm.$options,
34-
true, // partial
35-
this._host // important
30+
true // partial
3631
)
3732
cache.put(cacheId, this.linker)
3833
}
@@ -63,7 +58,7 @@ module.exports = {
6358

6459
link: function (frag, linker) {
6560
var vm = this.vm
66-
this.unlink = linker(vm, frag)
61+
this.unlink = linker(vm, frag, this._host /* important */)
6762
transition.blockAppend(frag, this.end, vm)
6863
// call attached for all the child components created
6964
// during the compilation

src/instance/init.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
var mergeOptions = require('../util').mergeOptions
2-
var uid = 0
32

43
/**
54
* The main init sequence. This is called for every
@@ -26,8 +25,6 @@ exports._init = function (options) {
2625
this._directives = [] // all directives
2726
this._childCtors = {} // inherit:true constructors
2827

29-
this._uid = uid++
30-
3128
// a flag to avoid this being observed
3229
this._isVue = true
3330

0 commit comments

Comments
 (0)