WordPress.org

Make WordPress Core

Ticket #43870: wp-emoji-loader.diff

File wp-emoji-loader.diff, 3.5 KB (added by nicollle, 3 years ago)
  • src/wp-includes/js/wp-emoji-loader.js

    diff --git src/wp-includes/js/wp-emoji-loader.js src/wp-includes/js/wp-emoji-loader.js
    index 8291c5b4cf..9faa0c5bd8 100644
     
    11( function( window, document, settings ) {
    22        var src, ready, ii, tests;
    33
    4         /*
    5          * Create a canvas element for testing native browser support
    6          * of emoji.
    7          */
     4
     5         //Create a canvas element for testing native browser support of emoji.
    86        var canvas = document.createElement( 'canvas' );
    97        var context = canvas.getContext && canvas.getContext( '2d' );
    108
    119        /**
    1210         * Check if two sets of Emoji characters render the same.
    1311         *
    14          * @param set1 array Set of Emoji characters.
    15          * @param set2 array Set of Emoji characters.
     12         * @ignore
     13         *
     14         * @since 4.9.0
     15         *
     16         * @param {array} set1 Set of Emoji characters.
     17         * @param {array} set2 Set of Emoji characters.
    1618         * @returns {boolean} True if the two sets render the same.
    1719         */
    1820        function emojiSetsRenderIdentically( set1, set2 ) {
     
    3234        }
    3335
    3436        /**
    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         * Detect if the browser supports rendering emoji or flag emoji.
     38         *
     39         * Flag emoji are a single glyph made of two characters,
     40         * so some browsers (notably, Firefox OS X) don't support them.
     41         *
     42         * @ignore
    3743         *
    3844         * @since 4.2.0
    3945         *
    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.
     46         * @param {string} type Whether to test for support of "flag" or "emoji".
     47         * @return {boolean} True if the browser can render emoji, false if it cannot.
    4248         */
    4349        function browserSupportsEmoji( type ) {
    4450                var isIdentical;
     
    103109
    104110                return false;
    105111        }
    106 
     112        /**
     113         * Adds a script to the head of the document.
     114         *
     115         * @ignore
     116         *
     117         * @since 4.2.0
     118         *
     119         * @param {object} src The path where the script is located.
     120         * @return {void}
     121         */
    107122        function addScript( src ) {
    108123                var script = document.createElement( 'script' );
    109124
     
    114129
    115130        tests = Array( 'flag', 'emoji' );
    116131
     132        // Defines the initial values to the supports prop of settings.
    117133        settings.supports = {
    118134                everything: true,
    119135                everythingExceptFlag: true
    120136        };
    121137
     138        // Tests the browser support for flag emojis and other emojis, and adjusts the support settings accordingly.
    122139        for( ii = 0; ii < tests.length; ii++ ) {
    123140                settings.supports[ tests[ ii ] ] = browserSupportsEmoji( tests[ ii ] );
    124141
     
    131148
    132149        settings.supports.everythingExceptFlag = settings.supports.everythingExceptFlag && ! settings.supports.flag;
    133150
     151        // Sets DOMReady to false and assigns a ready function to settings.
    134152        settings.DOMReady = false;
    135153        settings.readyCallback = function() {
    136154                settings.DOMReady = true;
    137155        };
    138156
     157        // When the browser can not render everything...
    139158        if ( ! settings.supports.everything ) {
    140159                ready = function() {
    141160                        settings.readyCallback();
    142161                };
    143162
     163                // Tests whether a document.addEventListener exists. This is the case for IE < 9.
     164                // On the load events set settings.DOMReady to true.
    144165                if ( document.addEventListener ) {
    145166                        document.addEventListener( 'DOMContentLoaded', ready, false );
    146167                        window.addEventListener( 'load', ready, false );
     
    153174                        } );
    154175                }
    155176
     177                // Adds scripts to the DOM if they are present in the settings.
    156178                src = settings.source || {};
    157179
    158180                if ( src.concatemoji ) {