@@ -6,6 +6,7 @@ describe('runtime-dom: props patching', () => {
6
6
const el = document . createElement ( 'div' )
7
7
patchProp ( el , 'id' , null , 'foo' )
8
8
expect ( el . id ) . toBe ( 'foo' )
9
+ // prop with string value should be set to empty string on null values
9
10
patchProp ( el , 'id' , null , null )
10
11
expect ( el . id ) . toBe ( '' )
11
12
} )
@@ -75,4 +76,20 @@ describe('runtime-dom: props patching', () => {
75
76
expect ( root . innerHTML ) . toBe ( `<div>bar</div>` )
76
77
expect ( fn ) . toHaveBeenCalled ( )
77
78
} )
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
+ } )
78
95
} )
0 commit comments