From 51579c49a8db85aeb1a03aaeee9a0844ea04bb70 Mon Sep 17 00:00:00 2001 From: Dominik Schilling Date: Tue, 5 Jul 2016 16:16:57 +0000 Subject: [PATCH] Embeds: After [37745], check if a featured image exists before attaching an event listener. Props swissspidy. Fixes #35657. Built from https://develop.svn.wordpress.org/trunk@37977 git-svn-id: http://core.svn.wordpress.org/trunk@37918 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/embed.php | 2 +- wp-includes/js/wp-embed-template.js | 9 ++++++--- wp-includes/js/wp-embed-template.min.js | 2 +- wp-includes/version.php | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/wp-includes/embed.php b/wp-includes/embed.php index aec5f598b3..7c533dd882 100644 --- a/wp-includes/embed.php +++ b/wp-includes/embed.php @@ -903,7 +903,7 @@ function print_embed_scripts() { * and edit wp-embed-template.js directly. */ ?> - !function(a,b){"use strict";function c(b,c){a.parent.postMessage({message:b,value:c,secret:g},"*")}function d(){function d(){l.className=l.className.replace("hidden",""),b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]').focus()}function e(){l.className+=" hidden",b.querySelector(".wp-embed-share-dialog-open").focus()}function f(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');c.setAttribute("aria-selected","false"),b.querySelector("#"+c.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),a.target.setAttribute("aria-selected","true"),b.querySelector("#"+a.target.getAttribute("aria-controls")).setAttribute("aria-hidden","false")}function g(a){var c,d,e=a.target,f=e.parentElement.previousElementSibling,g=e.parentElement.nextElementSibling;if(37===a.keyCode)c=f;else{if(39!==a.keyCode)return!1;c=g}"rtl"===b.documentElement.getAttribute("dir")&&(c=c===f?g:f),c&&(d=c.firstElementChild,e.setAttribute("tabindex","-1"),e.setAttribute("aria-selected",!1),b.querySelector("#"+e.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),d.setAttribute("tabindex","0"),d.setAttribute("aria-selected","true"),d.focus(),b.querySelector("#"+d.getAttribute("aria-controls")).setAttribute("aria-hidden","false"))}function h(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');n!==a.target||a.shiftKey?c===a.target&&a.shiftKey&&(n.focus(),a.preventDefault()):(c.focus(),a.preventDefault())}function i(a){var b,d=a.target;b=d.hasAttribute("href")?d.getAttribute("href"):d.parentElement.getAttribute("href"),b&&(c("link",b),a.preventDefault())}if(!k){k=!0;var j,l=b.querySelector(".wp-embed-share-dialog"),m=b.querySelector(".wp-embed-share-dialog-open"),n=b.querySelector(".wp-embed-share-dialog-close"),o=b.querySelectorAll(".wp-embed-share-input"),p=b.querySelectorAll(".wp-embed-share-tab-button button");if(o)for(j=0;j diff --git a/wp-includes/js/wp-embed-template.js b/wp-includes/js/wp-embed-template.js index 2960991cee..16f67080ea 100644 --- a/wp-includes/js/wp-embed-template.js +++ b/wp-includes/js/wp-embed-template.js @@ -26,6 +26,7 @@ share_dialog_close = document.querySelector( '.wp-embed-share-dialog-close' ), share_input = document.querySelectorAll( '.wp-embed-share-input' ), share_dialog_tabs = document.querySelectorAll( '.wp-embed-share-tab-button button' ), + featured_image = document.querySelector( '.wp-embed-featured-image img' ), i; if ( share_input ) { @@ -139,9 +140,11 @@ sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); // Send the document's height again after the featured image has been loaded. - document.querySelector( '.wp-embed-featured-image img' ).addEventListener( 'load', function() { - sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); - } ); + if ( featured_image ) { + featured_image.addEventListener( 'load', function() { + sendEmbedMessage( 'height', Math.ceil( document.body.getBoundingClientRect().height ) ); + } ); + } /** * Detect clicks to external (_top) links. diff --git a/wp-includes/js/wp-embed-template.min.js b/wp-includes/js/wp-embed-template.min.js index 40043b85a3..cbb96ed4ee 100644 --- a/wp-includes/js/wp-embed-template.min.js +++ b/wp-includes/js/wp-embed-template.min.js @@ -1 +1 @@ -!function(a,b){"use strict";function c(b,c){a.parent.postMessage({message:b,value:c,secret:g},"*")}function d(){function d(){l.className=l.className.replace("hidden",""),b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]').focus()}function e(){l.className+=" hidden",b.querySelector(".wp-embed-share-dialog-open").focus()}function f(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');c.setAttribute("aria-selected","false"),b.querySelector("#"+c.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),a.target.setAttribute("aria-selected","true"),b.querySelector("#"+a.target.getAttribute("aria-controls")).setAttribute("aria-hidden","false")}function g(a){var c,d,e=a.target,f=e.parentElement.previousElementSibling,g=e.parentElement.nextElementSibling;if(37===a.keyCode)c=f;else{if(39!==a.keyCode)return!1;c=g}"rtl"===b.documentElement.getAttribute("dir")&&(c=c===f?g:f),c&&(d=c.firstElementChild,e.setAttribute("tabindex","-1"),e.setAttribute("aria-selected",!1),b.querySelector("#"+e.getAttribute("aria-controls")).setAttribute("aria-hidden","true"),d.setAttribute("tabindex","0"),d.setAttribute("aria-selected","true"),d.focus(),b.querySelector("#"+d.getAttribute("aria-controls")).setAttribute("aria-hidden","false"))}function h(a){var c=b.querySelector('.wp-embed-share-tab-button [aria-selected="true"]');n!==a.target||a.shiftKey?c===a.target&&a.shiftKey&&(n.focus(),a.preventDefault()):(c.focus(),a.preventDefault())}function i(a){var b,d=a.target;b=d.hasAttribute("href")?d.getAttribute("href"):d.parentElement.getAttribute("href"),b&&(c("link",b),a.preventDefault())}if(!k){k=!0;var j,l=b.querySelector(".wp-embed-share-dialog"),m=b.querySelector(".wp-embed-share-dialog-open"),n=b.querySelector(".wp-embed-share-dialog-close"),o=b.querySelectorAll(".wp-embed-share-input"),p=b.querySelectorAll(".wp-embed-share-tab-button button");if(o)for(j=0;j