@@ -6,6 +6,7 @@ describe('runtime-dom: props patching', () => {
66    const  el  =  document . createElement ( 'div' ) 
77    patchProp ( el ,  'id' ,  null ,  'foo' ) 
88    expect ( el . id ) . toBe ( 'foo' ) 
9+     // prop with string value should be set to empty string on null values 
910    patchProp ( el ,  'id' ,  null ,  null ) 
1011    expect ( el . id ) . toBe ( '' ) 
1112  } ) 
@@ -75,4 +76,20 @@ describe('runtime-dom: props patching', () => {
7576    expect ( root . innerHTML ) . toBe ( `<div>bar</div>` ) 
7677    expect ( fn ) . toHaveBeenCalled ( ) 
7778  } ) 
79+ 
80+   // #1049 
81+   test ( 'set value as-is for non string-value props' ,  ( )  =>  { 
82+     const  el  =  document . createElement ( 'video' ) 
83+     // jsdom doesn't really support video playback. srcObject in a real browser 
84+     // should default to `null`, but in jsdom it's `undefined`. 
85+     // anyway, here we just want to make sure Vue doesn't set non-string props 
86+     // to an empty string on nullish values - it should reset to its default 
87+     // value. 
88+     const  intiialValue  =  el . srcObject 
89+     const  fakeObject  =  { } 
90+     patchProp ( el ,  'srcObject' ,  null ,  fakeObject ) 
91+     expect ( el . srcObject ) . not . toBe ( fakeObject ) 
92+     patchProp ( el ,  'srcObject' ,  null ,  null ) 
93+     expect ( el . srcObject ) . toBe ( intiialValue ) 
94+   } ) 
7895} ) 
0 commit comments