Embeds: Remove & characters from the inline embed JS.

Older versions of WordPress will convert those `&` characters to `&`, which makes for some non-functional JS. If folks are running an older release, let's not make their lives more difficult than it already is.

Props pento, peterwilsoncc.

See #34698.



git-svn-id: https://develop.svn.wordpress.org/trunk@35708 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast
2015-11-19 23:05:39 +00:00
parent 71c0c35c24
commit c7e05dafbe
2 changed files with 34 additions and 10 deletions

View File

@@ -1,9 +1,15 @@
(function ( window, document ) {
'use strict';
var supportedBrowser = ( document.querySelector && window.addEventListener ),
var supportedBrowser = false,
loaded = false;
if ( document.querySelector ) {
if ( window.addEventListener ) {
supportedBrowser = true;
}
}
window.wp = window.wp || {};
if ( !! window.wp.receiveEmbedMessage ) {
@@ -50,8 +56,10 @@
targetURL.href = data.value;
/* Only continue if link hostname matches iframe's hostname. */
if ( targetURL.host === sourceURL.host && document.activeElement === source ) {
window.top.location.href = data.value;
if ( targetURL.host === sourceURL.host ) {
if ( document.activeElement === source ) {
window.top.location.href = data.value;
}
}
}
}
@@ -77,15 +85,17 @@
source = iframes[ i ];
source.style.display = '';
if ( !source.getAttribute( 'data-secret' ) ) {
/* Add secret to iframe */
secret = Math.random().toString( 36 ).substr( 2, 10 );
source.src += '#?secret=' + secret;
source.setAttribute( 'data-secret', secret );
if ( source.getAttribute( 'data-secret' ) ) {
continue;
}
/* Add secret to iframe */
secret = Math.random().toString( 36 ).substr( 2, 10 );
source.src += '#?secret=' + secret;
source.setAttribute( 'data-secret', secret );
/* Remove security attribute from iframes in IE10 and IE11. */
if ( ( isIE10 || isIE11 ) && !!source.getAttribute( 'security' ) ) {
if ( ( isIE10 || isIE11 ) ) {
iframeClone = source.cloneNode( true );
iframeClone.removeAttribute( 'security' );
source.parentNode.replaceChild( iframeClone, source );