mirror of https://github.com/vuejs/core.git
				
				
				
			fix(custom-element): avoid setting attr to null if it is removed (#9012)
Partially fixes #9006 Fixes #10324
This commit is contained in:
		
							parent
							
								
									cde47bfa97
								
							
						
					
					
						commit
						b49306adff
					
				| 
						 | 
				
			
			@ -139,6 +139,12 @@ describe('defineCustomElement', () => {
 | 
			
		|||
      expect(e.shadowRoot!.innerHTML).toBe('<div></div><div>two</div>')
 | 
			
		||||
      expect(e.hasAttribute('foo')).toBe(false)
 | 
			
		||||
 | 
			
		||||
      e.foo = undefined
 | 
			
		||||
      await nextTick()
 | 
			
		||||
      expect(e.shadowRoot!.innerHTML).toBe('<div></div><div>two</div>')
 | 
			
		||||
      expect(e.hasAttribute('foo')).toBe(false)
 | 
			
		||||
      expect(e.foo).toBe(undefined)
 | 
			
		||||
 | 
			
		||||
      e.bazQux = 'four'
 | 
			
		||||
      await nextTick()
 | 
			
		||||
      expect(e.shadowRoot!.innerHTML).toBe('<div></div><div>four</div>')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -313,7 +313,7 @@ export class VueElement extends BaseClass {
 | 
			
		|||
  }
 | 
			
		||||
 | 
			
		||||
  protected _setAttr(key: string) {
 | 
			
		||||
    let value = this.getAttribute(key)
 | 
			
		||||
    let value = this.hasAttribute(key) ? this.getAttribute(key) : undefined
 | 
			
		||||
    const camelKey = camelize(key)
 | 
			
		||||
    if (this._numberProps && this._numberProps[camelKey]) {
 | 
			
		||||
      value = toNumber(value)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue