Ticket #32109: 32109.3.diff
File 32109.3.diff, 4.0 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/wp-emoji-loader.js
1 1 ( function( window, document, settings ) { 2 var src ;2 var src, ready; 3 3 4 4 /** 5 5 * Detect if the browser supports rendering emoji or flag emoji. Flag emoji are a single glyph … … 62 62 flag: browserSupportsEmoji( 'flag' ) 63 63 }; 64 64 65 settings.DOMReady = false; 66 settings.readyCallback = function() { 67 settings.DOMReady = true; 68 }; 69 65 70 if ( ! settings.supports.simple || ! settings.supports.flag ) { 71 ready = function() { 72 settings.readyCallback(); 73 }; 74 75 if ( document.addEventListener ) { 76 document.addEventListener( 'DOMContentLoaded', ready, false ); 77 window.addEventListener( 'load', ready, false ); 78 } else { 79 window.attachEvent( 'onload', ready ); 80 document.attachEvent( 'onreadystatechange', function() { 81 if ( 'complete' === document.readyState ) { 82 settings.readyCallback(); 83 } 84 } ); 85 } 86 66 87 src = settings.source || {}; 67 88 68 89 if ( src.concatemoji ) { -
src/wp-includes/js/wp-emoji.js
4 4 var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, 5 5 6 6 /** 7 * Flag to determine if the browser and the OS support emoji.8 *9 * @since 4.2.010 *11 * @var Boolean12 */13 supportsEmoji = false,14 15 /**16 * Flag to determine if the browser and the OS support flag (two character) emoji.17 *18 * @since 4.2.019 *20 * @var Boolean21 */22 supportsFlagEmoji = false,23 24 /**25 7 * Flag to determine if we should replace emoji characters with images. 26 8 * 27 9 * @since 4.2.0 … … 30 12 */ 31 13 replaceEmoji = false, 32 14 33 isIE8 = window.navigator.userAgent.indexOf( 'IE 8' ) !== -1,34 35 15 // Private 36 16 twemoji, timer, 17 loaded = false, 37 18 count = 0; 38 19 39 20 /** … … 42 23 * @since 4.2.0 43 24 */ 44 25 function load() { 26 if ( loaded ) { 27 return; 28 } 29 45 30 if ( typeof window.twemoji === 'undefined' ) { 46 31 // Break if waiting for longer than 30 sec. 47 32 if ( count > 600 ) { … … 57 42 } 58 43 59 44 twemoji = window.twemoji; 45 loaded = true; 60 46 61 47 if ( MutationObserver ) { 62 48 new MutationObserver( function( mutationRecords ) { … … 96 82 * @param {Object} args Additional options for Twemoji. 97 83 */ 98 84 function parse( object, args ) { 99 if ( ! replaceEmoji ) {85 if ( ! replaceEmoji || ! twemoji ) { 100 86 return object; 101 87 } 102 88 … … 121 107 return false; 122 108 } 123 109 124 if ( ! s upportsFlagEmoji && supportsEmoji&&110 if ( ! settings.supports.flag && settings.supports.simple && 125 111 ! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) ) { 126 112 127 113 return false; … … 132 118 } ); 133 119 } 134 120 135 // Load when the readyState changes to 'interactive', not 'complete'.136 function onLoad() {137 if ( ( ! isIE8 && 'interactive' === document.readyState ) || ( isIE8 && 'complete' === document.readyState ) ) {138 load();139 }140 }141 142 121 /** 143 122 * Initialize our emoji support, and set up listeners. 144 123 */ 145 124 if ( settings ) { 146 supportsEmoji = window._wpemojiSettings.supports.simple; 147 supportsFlagEmoji = window._wpemojiSettings.supports.flag; 148 replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji; 125 replaceEmoji = ! settings.supports.simple || ! settings.supports.flag; 149 126 150 if ( ( ! isIE8 && 'loading' === document.readyState ) || ( isIE8 && 'complete' !== document.readyState ) ) { 151 if ( document.addEventListener ) { 152 document.addEventListener( 'readystatechange', onLoad, false ); 153 } else if ( document.attachEvent ) { 154 document.attachEvent( 'onreadystatechange', onLoad ); 155 } 127 if ( settings.DOMReady ) { 128 load(); 156 129 } else { 157 load();130 settings.readyCallback = load; 158 131 } 159 132 } 160 133