parent
							
								
									00ab9e2e85
								
							
						
					
					
						commit
						cb6a0915c5
					
				@ -107,4 +107,21 @@ describe('runtime-dom: props patching', () => {
 | 
			
		||||
 | 
			
		||||
    expect(`Failed setting prop "someProp" on <div>`).toHaveBeenWarnedLast()
 | 
			
		||||
  })
 | 
			
		||||
 | 
			
		||||
  // #1576
 | 
			
		||||
  test('remove attribute when value is falsy', () => {
 | 
			
		||||
    const el = document.createElement('div')
 | 
			
		||||
    patchProp(el, 'id', null, '')
 | 
			
		||||
    expect(el.hasAttribute('id')).toBe(true)
 | 
			
		||||
    patchProp(el, 'id', null, null)
 | 
			
		||||
    expect(el.hasAttribute('id')).toBe(false)
 | 
			
		||||
 | 
			
		||||
    patchProp(el, 'id', null, '')
 | 
			
		||||
    expect(el.hasAttribute('id')).toBe(true)
 | 
			
		||||
    patchProp(el, 'id', null, undefined)
 | 
			
		||||
    expect(el.hasAttribute('id')).toBe(false)
 | 
			
		||||
 | 
			
		||||
    patchProp(el, 'id', null, '')
 | 
			
		||||
    expect(el.hasAttribute('id')).toBe(true)
 | 
			
		||||
  })
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
@ -37,6 +37,7 @@ export function patchDOMProp(
 | 
			
		||||
  } else if (value == null && typeof el[key] === 'string') {
 | 
			
		||||
    // e.g. <div :id="null">
 | 
			
		||||
    el[key] = ''
 | 
			
		||||
    el.removeAttribute(key)
 | 
			
		||||
  } else {
 | 
			
		||||
    // some properties perform value validation and throw
 | 
			
		||||
    try {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user