mirror of https://github.com/vuejs/vue.git
				
				
				
			fix #539 v-if duplicate compile when a different truthy value is set
This commit is contained in:
		
							parent
							
								
									ee2ae353da
								
							
						
					
					
						commit
						78fa71cc6f
					
				| 
						 | 
					@ -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)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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({
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue