@@ -9,6 +9,7 @@ describe('runtime-dom: props patching', () => {
99 // prop with string value should be set to empty string on null values
1010 patchProp ( el , 'id' , null , null )
1111 expect ( el . id ) . toBe ( '' )
12+ expect ( el . getAttribute ( 'id' ) ) . toBe ( null )
1213 } )
1314
1415 test ( 'value' , ( ) => {
@@ -17,12 +18,25 @@ describe('runtime-dom: props patching', () => {
1718 expect ( el . value ) . toBe ( 'foo' )
1819 patchProp ( el , 'value' , null , null )
1920 expect ( el . value ) . toBe ( '' )
21+ expect ( el . getAttribute ( 'value' ) ) . toBe ( null )
2022 const obj = { }
2123 patchProp ( el , 'value' , null , obj )
2224 expect ( el . value ) . toBe ( obj . toString ( ) )
2325 expect ( ( el as any ) . _value ) . toBe ( obj )
2426 } )
2527
28+ // For <input type="text">, setting el.value won't create a `value` attribute
29+ // so we need to add tests for other elements
30+ test ( 'value for non-text input' , ( ) => {
31+ const el = document . createElement ( 'option' )
32+ patchProp ( el , 'value' , null , 'foo' )
33+ expect ( el . value ) . toBe ( 'foo' )
34+ patchProp ( el , 'value' , null , null )
35+ expect ( el . value ) . toBe ( '' )
36+ // #3475
37+ expect ( el . getAttribute ( 'value' ) ) . toBe ( null )
38+ } )
39+
2640 test ( 'boolean prop' , ( ) => {
2741 const el = document . createElement ( 'select' )
2842 patchProp ( el , 'multiple' , null , '' )
0 commit comments