fix #539 v-if duplicate compile when a different truthy value is set

This commit is contained in:
Evan You 2014-11-03 18:42:19 -05:00
parent ee2ae353da
commit 78fa71cc6f
2 changed files with 21 additions and 0 deletions

View File

@ -43,6 +43,11 @@ module.exports = {
}, },
insert: function () { insert: function () {
// avoid duplicate inserts, since update() can be
// called with different truthy values
if (this.decompile) {
return
}
var vm = this.vm var vm = this.vm
var frag = templateParser.clone(this.template) var frag = templateParser.clone(this.template)
var decompile = this.linker(vm, frag) var decompile = this.linker(vm, frag)

View File

@ -145,6 +145,22 @@ if (_.inBrowser) {
}) })
}) })
it('v-if with different truthy values', function (done) {
var vm = new Vue({
el: el,
data: {
a: 1
},
template: '<div v-if="a">{{a}}</div>'
})
expect(el.innerHTML).toBe(wrap('<div>1</div>'))
vm.a = 2
_.nextTick(function () {
expect(el.innerHTML).toBe(wrap('<div>2</div>'))
done()
})
})
it('invalid warn', function () { it('invalid warn', function () {
el.setAttribute('v-if', 'test') el.setAttribute('v-if', 'test')
var vm = new Vue({ var vm = new Vue({