compile v-if content with correct transclusion host (fix #1097)

This commit is contained in:
Evan You 2015-07-30 09:50:04 -04:00
parent eb5c80adcd
commit 3483db2ced
2 changed files with 30 additions and 1 deletions

View File

@ -27,7 +27,8 @@ module.exports = {
this.linker = compiler.compile(
this.template,
this.vm.$options,
true
true, // partial
this._host // important
)
cache.put(cacheId, this.linker)
}

View File

@ -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)
})
})
}