@@ -70,7 +70,8 @@ function shouldUpdatePlayer(prevProps, props) {
70
70
prevProps . id !== props . id ||
71
71
prevProps . className !== props . className ||
72
72
prevProps . opts . width !== props . opts . width ||
73
- prevProps . opts . height !== props . opts . height
73
+ prevProps . opts . height !== props . opts . height ||
74
+ prevProps . title !== props . title
74
75
) ;
75
76
}
76
77
@@ -226,6 +227,8 @@ class YouTube extends React.Component {
226
227
else iframe . removeAttribute ( 'width' ) ;
227
228
if ( this . props . opts && this . props . opts . height ) iframe . setAttribute ( 'height' , this . props . opts . height ) ;
228
229
else iframe . removeAttribute ( 'height' ) ;
230
+ if ( typeof this . props . title === 'string' ) iframe . setAttribute ( 'title' , this . props . title ) ;
231
+ else iframe . setAttribute ( 'title' , 'YouTube video player' ) ;
229
232
} ) ;
230
233
} ;
231
234
@@ -294,6 +297,8 @@ YouTube.propTypes = {
294
297
className : PropTypes . string ,
295
298
// custom class name for player container element
296
299
containerClassName : PropTypes . string ,
300
+ // custom title for the iFrame, see https://www.w3.org/TR/WCAG20-TECHS/H64.html
301
+ title : PropTypes . string ,
297
302
298
303
// custom loading for player element
299
304
loading : PropTypes . oneOf ( [ 'lazy' , 'eager' , 'auto' ] ) ,
@@ -327,6 +332,7 @@ YouTube.defaultProps = {
327
332
onStateChange : ( ) => { } ,
328
333
onPlaybackRateChange : ( ) => { } ,
329
334
onPlaybackQualityChange : ( ) => { } ,
335
+ title : null ,
330
336
} ;
331
337
332
338
export default YouTube ;
0 commit comments