diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index c49de1a155d..88cf916252b 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -24,6 +24,14 @@ describe('runtime-dom: props patching', () => { patchProp(el, 'value', null, obj) expect(el.value).toBe(obj.toString()) expect((el as any)._value).toBe(obj) + + const option = document.createElement('option') + patchProp(option, 'textContent', null, 'foo') + expect(option.value).toBe('foo') + expect(option.getAttribute('value')).toBe(null) + patchProp(option, 'value', null, 'foo') + expect(option.value).toBe('foo') + expect(option.getAttribute('value')).toBe('foo') }) test('value for custom elements', () => { diff --git a/packages/runtime-dom/src/modules/props.ts b/packages/runtime-dom/src/modules/props.ts index 1c1ad0c16f7..cdf9d84cf5d 100644 --- a/packages/runtime-dom/src/modules/props.ts +++ b/packages/runtime-dom/src/modules/props.ts @@ -26,23 +26,22 @@ export function patchDOMProp( return } + const tag = el.tagName + if ( key === 'value' && - el.tagName !== 'PROGRESS' && + tag !== 'PROGRESS' && // custom elements may use _value internally - !el.tagName.includes('-') + !tag.includes('-') ) { // store value as _value as well since // non-string values will be stringified. el._value = value + // #4956: