avoid npe on iframe postMessage
This commit is contained in:
		| @@ -3377,20 +3377,20 @@ | |||||||
|  |  | ||||||
| 			// Generic postMessage API for non-lazy loaded iframes | 			// Generic postMessage API for non-lazy loaded iframes | ||||||
| 			toArray( element.querySelectorAll( 'iframe' ) ).forEach( function( el ) { | 			toArray( element.querySelectorAll( 'iframe' ) ).forEach( function( el ) { | ||||||
| 				el.contentWindow.postMessage( 'slide:stop', '*' ); | 				if( el.contentWindow ) el.contentWindow.postMessage( 'slide:stop', '*' ); | ||||||
| 				el.removeEventListener( 'load', startEmbeddedIframe ); | 				el.removeEventListener( 'load', startEmbeddedIframe ); | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
| 			// YouTube postMessage API | 			// YouTube postMessage API | ||||||
| 			toArray( element.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) { | 			toArray( element.querySelectorAll( 'iframe[src*="youtube.com/embed/"]' ) ).forEach( function( el ) { | ||||||
| 				if( !el.hasAttribute( 'data-ignore' ) && typeof el.contentWindow.postMessage === 'function' ) { | 				if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) { | ||||||
| 					el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' ); | 					el.contentWindow.postMessage( '{"event":"command","func":"pauseVideo","args":""}', '*' ); | ||||||
| 				} | 				} | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
| 			// Vimeo postMessage API | 			// Vimeo postMessage API | ||||||
| 			toArray( element.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) { | 			toArray( element.querySelectorAll( 'iframe[src*="player.vimeo.com/"]' ) ).forEach( function( el ) { | ||||||
| 				if( !el.hasAttribute( 'data-ignore' ) && typeof el.contentWindow.postMessage === 'function' ) { | 				if( !el.hasAttribute( 'data-ignore' ) && el.contentWindow && typeof el.contentWindow.postMessage === 'function' ) { | ||||||
| 					el.contentWindow.postMessage( '{"method":"pause"}', '*' ); | 					el.contentWindow.postMessage( '{"method":"pause"}', '*' ); | ||||||
| 				} | 				} | ||||||
| 			}); | 			}); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user