diff --git a/packages/runtime-dom/__tests__/patchProps.spec.ts b/packages/runtime-dom/__tests__/patchProps.spec.ts index 7c356f1a66c..61dd98513ce 100644 --- a/packages/runtime-dom/__tests__/patchProps.spec.ts +++ b/packages/runtime-dom/__tests__/patchProps.spec.ts @@ -291,6 +291,18 @@ describe('runtime-dom: props patching', () => { expect(el.value).toBe('baz') }) + test('init empty value for option', () => { + const root = document.createElement('div') + render( + h('select', { value: 'foo' }, [h('option', { value: '' }, 'foo')]), + root, + ) + const select = root.children[0] as HTMLSelectElement + const option = select.children[0] as HTMLOptionElement + expect(select.value).toBe('') + expect(option.value).toBe('') + }) + // #8780 test('embedded tag with width and height', () => { // Width and height of some embedded element such as img、video、source、canvas diff --git a/packages/runtime-dom/src/modules/props.ts b/packages/runtime-dom/src/modules/props.ts index e9b3bca357d..c4bb4987b8c 100644 --- a/packages/runtime-dom/src/modules/props.ts +++ b/packages/runtime-dom/src/modules/props.ts @@ -34,20 +34,20 @@ export function patchDOMProp( // custom elements may use _value internally !tag.includes('-') ) { - // store value as _value as well since - // non-string values will be stringified. - el._value = value // #4956: