Embeds: Add fallbacks for IE7-9.
Older IE versions need just that little bit of extra tender care to keep them going. Props peterwilsoncc, swissspidy, pento. Fixes #34204. Built from https://develop.svn.wordpress.org/trunk@35466 git-svn-id: http://core.svn.wordpress.org/trunk@35430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
(function ( window, document ) {
|
||||
'use strict';
|
||||
|
||||
var supportedBrowser = ( document.querySelector && window.addEventListener ),
|
||||
loaded = false;
|
||||
|
||||
window.wp = window.wp || {};
|
||||
|
||||
if ( !! window.wp.receiveEmbedMessage ) {
|
||||
@@ -54,9 +57,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener( 'message', window.wp.receiveEmbedMessage, false );
|
||||
|
||||
function onLoad() {
|
||||
if ( loaded ) {
|
||||
return;
|
||||
}
|
||||
loaded = true;
|
||||
|
||||
var isIE10 = -1 !== navigator.appVersion.indexOf( 'MSIE 10' ),
|
||||
isIE11 = !!navigator.userAgent.match( /Trident.*rv\:11\./ ),
|
||||
iframes, iframeClone, i;
|
||||
@@ -68,11 +74,14 @@
|
||||
for ( i = 0; i < iframes.length; i++ ) {
|
||||
iframeClone = iframes[ i ].cloneNode( true );
|
||||
iframeClone.removeAttribute( 'security' );
|
||||
iframes[ i ].parentNode.insertBefore( iframeClone, iframes[ i ].nextSibling );
|
||||
iframes[ i ].parentNode.removeChild( iframes[ i ] );
|
||||
iframes[ i ].parentNode.replaceChild( iframeClone, iframes[ i ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener( 'DOMContentLoaded', onLoad, false );
|
||||
if ( supportedBrowser ) {
|
||||
window.addEventListener( 'message', window.wp.receiveEmbedMessage, false );
|
||||
document.addEventListener( 'DOMContentLoaded', onLoad, false );
|
||||
window.addEventListener( 'load', onLoad, false );
|
||||
}
|
||||
})( window, document );
|
||||
|
||||
Reference in New Issue
Block a user