File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -33,11 +33,13 @@ function shouldUpdateVideo(prevProps, props) {
33
33
function filterResetOptions ( opts ) {
34
34
return {
35
35
...opts ,
36
+ height : 0 ,
37
+ width : 0 ,
36
38
playerVars : {
39
+ ...opts . playerVars ,
37
40
autoplay : 0 ,
38
41
start : 0 ,
39
42
end : 0 ,
40
- ...opts . playerVars ,
41
43
} ,
42
44
} ;
43
45
}
@@ -62,7 +64,8 @@ function shouldResetPlayer(prevProps, props) {
62
64
* @param {Object } props
63
65
*/
64
66
function shouldUpdatePlayer ( prevProps , props ) {
65
- return prevProps . id !== props . id || prevProps . className !== props . className ;
67
+ return prevProps . id !== props . id || prevProps . className !== props . className
68
+ || prevProps . opts . width !== props . opts . width || prevProps . opts . height !== props . opts . height ;
66
69
}
67
70
68
71
class YouTube extends React . Component {
@@ -213,6 +216,10 @@ class YouTube extends React.Component {
213
216
else iframe . removeAttribute ( 'id' ) ;
214
217
if ( this . props . className ) iframe . setAttribute ( 'class' , this . props . className ) ;
215
218
else iframe . removeAttribute ( 'class' ) ;
219
+ if ( this . props . opts && this . props . opts . width ) iframe . setAttribute ( 'width' , this . props . opts . width ) ;
220
+ else iframe . removeAttribute ( 'width' ) ;
221
+ if ( this . props . opts && this . props . opts . height ) iframe . setAttribute ( 'height' , this . props . opts . height ) ;
222
+ else iframe . removeAttribute ( 'height' ) ;
216
223
} ) ;
217
224
} ;
218
225
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ describe('YouTube', () => {
117
117
width : '480px' ,
118
118
height : '360px' ,
119
119
playerVars : {
120
+ height : 0 , // changed, does not force destroy & rebind
121
+ width : 0 , // changed, does not force destroy & rebind
120
122
autoplay : 1 , // changed, does not force destroy & rebind
121
123
start : 10 , // changed, does not force destroy & rebind
122
124
end : 20 , // changed, does not force destroy & rebind
You can’t perform that action at this time.
0 commit comments