Changeset 43143
- Timestamp:
- 05/03/2018 03:08:39 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/wp-emoji-loader.js
r42602 r43143 2 2 var src, ready, ii, tests; 3 3 4 /* 5 * Create a canvas element for testing native browser support 6 * of emoji. 7 */ 4 // Create a canvas element for testing native browser support of emoji. 8 5 var canvas = document.createElement( 'canvas' ); 9 6 var context = canvas.getContext && canvas.getContext( '2d' ); 10 7 11 8 /** 12 * Check if two sets of Emoji characters render the same.9 * Checks if two sets of Emoji characters render the same visually. 13 10 * 14 * @param set1 array Set of Emoji characters. 15 * @param set2 array Set of Emoji characters. 16 * @returns {boolean} True if the two sets render the same. 11 * @since 4.9.0 12 * 13 * @private 14 * 15 * @param {number[]} set1 Set of Emoji character codes. 16 * @param {number[]} set2 Set of Emoji character codes. 17 * 18 * @return {boolean} True if the two sets render the same. 17 19 */ 18 20 function emojiSetsRenderIdentically( set1, set2 ) { … … 33 35 34 36 /** 35 * Detect if the browser supports rendering emoji or flag emoji. Flag emoji are a single glyph 36 * made of two characters, so some browsers (notably, Firefox OS X) don't support them. 37 * Detects if the browser supports rendering emoji or flag emoji. 38 * 39 * Flag emoji are a single glyph made of two characters, so some browsers 40 * (notably, Firefox OS X) don't support them. 37 41 * 38 42 * @since 4.2.0 39 43 * 40 * @param type {String} Whether to test for support of "flag" or "emoji". 41 * @return {Boolean} True if the browser can render emoji, false if it cannot. 44 * @private 45 * 46 * @param {string} type Whether to test for support of "flag" or "emoji". 47 * 48 * @return {boolean} True if the browser can render emoji, false if it cannot. 42 49 */ 43 50 function browserSupportsEmoji( type ) { … … 105 112 } 106 113 114 /** 115 * Adds a script to the head of the document. 116 * 117 * @ignore 118 * 119 * @since 4.2.0 120 * 121 * @param {Object} src The url where the script is located. 122 * @return {void} 123 */ 107 124 function addScript( src ) { 108 125 var script = document.createElement( 'script' ); … … 120 137 }; 121 138 139 /* 140 * Tests the browser support for flag emojis and other emojis, and adjusts the 141 * support settings accordingly. 142 */ 122 143 for( ii = 0; ii < tests.length; ii++ ) { 123 144 settings.supports[ tests[ ii ] ] = browserSupportsEmoji( tests[ ii ] ); … … 132 153 settings.supports.everythingExceptFlag = settings.supports.everythingExceptFlag && ! settings.supports.flag; 133 154 155 // Sets DOMReady to false and assigns a ready function to settings. 134 156 settings.DOMReady = false; 135 157 settings.readyCallback = function() { … … 137 159 }; 138 160 161 // When the browser can not render everything we need to load a polyfill. 139 162 if ( ! settings.supports.everything ) { 140 163 ready = function() { … … 142 165 }; 143 166 167 /* 168 * Cross-browser version of adding a dom ready event. 169 */ 144 170 if ( document.addEventListener ) { 145 171 document.addEventListener( 'DOMContentLoaded', ready, false );
Note: See TracChangeset
for help on using the changeset viewer.