wp/wp-includes/js/wp-emoji.js
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 21 48c4eec2b7e6
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     7 
     7 
     8 ( function( window, settings ) {
     8 ( function( window, settings ) {
     9 	/**
     9 	/**
    10 	 * Replaces emoji with images when browsers don't support emoji.
    10 	 * Replaces emoji with images when browsers don't support emoji.
    11 	 *
    11 	 *
    12 	 * @since      4.2.0
    12 	 * @since 4.2.0
    13 	 * @access     private
    13 	 * @access private
    14 	 *
    14 	 *
    15 	 * @class
    15 	 * @class
    16 	 *
    16 	 *
    17 	 * @see  Twitter Emoji library
    17 	 * @see  Twitter Emoji library
    18 	 * @link https://github.com/twitter/twemoji
    18 	 * @link https://github.com/twitter/twemoji
    20 	 * @return {Object} The wpEmoji parse and test functions.
    20 	 * @return {Object} The wpEmoji parse and test functions.
    21 	 */
    21 	 */
    22 	function wpEmoji() {
    22 	function wpEmoji() {
    23 		var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
    23 		var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
    24 
    24 
    25 		// Compression and maintain local scope
    25 		// Compression and maintain local scope.
    26 		document = window.document,
    26 		document = window.document,
    27 
    27 
    28 		// Private
    28 		// Private.
    29 		twemoji, timer,
    29 		twemoji, timer,
    30 		loaded = false,
    30 		loaded = false,
    31 		count = 0,
    31 		count = 0,
    32 		ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0;
    32 		ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0;
    33 
    33 
    67 				return;
    67 				return;
    68 			}
    68 			}
    69 
    69 
    70 			// Ensure twemoji is available on the global window before proceeding.
    70 			// Ensure twemoji is available on the global window before proceeding.
    71 			if ( typeof window.twemoji === 'undefined' ) {
    71 			if ( typeof window.twemoji === 'undefined' ) {
    72 				// Break if waiting for longer than 30 sec.
    72 				// Break if waiting for longer than 30 seconds.
    73 				if ( count > 600 ) {
    73 				if ( count > 600 ) {
    74 					return;
    74 					return;
    75 				}
    75 				}
    76 
    76 
    77 				// Still waiting.
    77 				// Still waiting.
   243 						case '2666':
   243 						case '2666':
   244 							return false;
   244 							return false;
   245 					}
   245 					}
   246 
   246 
   247 					if ( settings.supports.everythingExceptFlag &&
   247 					if ( settings.supports.everythingExceptFlag &&
   248 						! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags
   248 						! /^1f1(?:e[6-9a-f]|f[0-9a-f])-1f1(?:e[6-9a-f]|f[0-9a-f])$/.test( icon ) && // Country flags.
   249 						! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon )             // Rainbow and pirate flags
   249 						! /^(1f3f3-fe0f-200d-1f308|1f3f4-200d-2620-fe0f)$/.test( icon )             // Rainbow and pirate flags.
   250 					) {
   250 					) {
   251 						return false;
   251 						return false;
   252 					}
   252 					}
   253 
   253 
   254 					return ''.concat( options.base, icon, options.ext );
   254 					return ''.concat( options.base, icon, options.ext );
       
   255 				},
       
   256 				attributes: function() {
       
   257 					return {
       
   258 						role: 'img'
       
   259 					};
   255 				},
   260 				},
   256 				onerror: function() {
   261 				onerror: function() {
   257 					if ( twemoji.parentNode ) {
   262 					if ( twemoji.parentNode ) {
   258 						this.setAttribute( 'data-error', 'load-failed' );
   263 						this.setAttribute( 'data-error', 'load-failed' );
   259 						twemoji.parentNode.replaceChild( document.createTextNode( twemoji.alt ), twemoji );
   264 						twemoji.parentNode.replaceChild( document.createTextNode( twemoji.alt ), twemoji );