Make WordPress Core

Ticket #32109: 32109.1.diff

File 32109.1.diff, 1.7 KB (added by peterwilsoncc, 8 years ago)

Ensure document.body is defined

  • src/wp-includes/js/wp-emoji.js

    diff --git a/src/wp-includes/js/wp-emoji.js b/src/wp-includes/js/wp-emoji.js
    index 0ff3c6f..3867ace 100644
    a b  
    3030                 */
    3131                replaceEmoji = false,
    3232
    33                 isIE8 = window.navigator.userAgent.indexOf( 'IE 8' ) !== -1,
     33                isLegacyIE = (window.navigator.userAgent.indexOf( 'IE 8' ) !== -1) || (window.navigator.userAgent.indexOf( 'IE 9' ) !== -1) || (window.navigator.userAgent.indexOf( 'IE 10' ) !== -1),
    3434
    3535                // Private
    3636                twemoji, timer,
     
    4242                 * @since 4.2.0
    4343                 */
    4444                function load() {
    45                         if ( typeof window.twemoji === 'undefined' ) {
     45                        if( ( typeof window.twemoji === 'undefined' ) || ( document.body === null ) || ( typeof document.body === 'undefined' ) ){
    4646                                // Break if waiting for longer than 30 sec.
    4747                                if ( count > 600 ) {
    4848                                        return;
     
    134134
    135135                // Load when the readyState changes to 'interactive', not 'complete'.
    136136                function onLoad() {
    137                         if ( ( ! isIE8 && 'interactive' === document.readyState ) || ( isIE8 && 'complete' === document.readyState ) ) {
     137                        if ( ( ! isLegacyIE && 'interactive' === document.readyState ) || ( isLegacyIE && 'complete' === document.readyState ) ) {
    138138                                load();
    139139                        }
    140140                }
     
    147147                        supportsFlagEmoji = window._wpemojiSettings.supports.flag;
    148148                        replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji;
    149149
    150                         if ( ( ! isIE8 && 'loading' === document.readyState ) || ( isIE8 && 'complete' !== document.readyState ) ) {
     150                        if ( ( ! isLegacyIE && 'loading' === document.readyState ) || ( isLegacyIE && 'complete' !== document.readyState ) ) {
    151151                                if ( document.addEventListener ) {
    152152                                        document.addEventListener( 'readystatechange', onLoad, false );
    153153                                } else if ( document.attachEvent ) {