mirror of https://github.com/vuejs/vue.git
compile v-if content with correct transclusion host (fix #1097)
This commit is contained in:
parent
eb5c80adcd
commit
3483db2ced
|
@ -27,7 +27,8 @@ module.exports = {
|
||||||
this.linker = compiler.compile(
|
this.linker = compiler.compile(
|
||||||
this.template,
|
this.template,
|
||||||
this.vm.$options,
|
this.vm.$options,
|
||||||
true
|
true, // partial
|
||||||
|
this._host // important
|
||||||
)
|
)
|
||||||
cache.put(cacheId, this.linker)
|
cache.put(cacheId, this.linker)
|
||||||
}
|
}
|
||||||
|
|
|
@ -327,5 +327,33 @@ if (_.inBrowser) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #1097 v-if components not having correct parent
|
||||||
|
it('compile with correct transclusion host', function () {
|
||||||
|
var parentA
|
||||||
|
var parentB
|
||||||
|
new Vue({
|
||||||
|
el: el,
|
||||||
|
data: {
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
template: '<parent><child v-if="show"></child></parent>',
|
||||||
|
components: {
|
||||||
|
parent: {
|
||||||
|
template: '<content></content>',
|
||||||
|
created: function () {
|
||||||
|
parentA = this
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: {
|
||||||
|
created: function () {
|
||||||
|
parentB = this.$parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(parentA).toBeTruthy()
|
||||||
|
expect(parentA).toBe(parentB)
|
||||||
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue