WordPress.org

Make WordPress Core

Changeset 43143


Ignore:
Timestamp:
05/03/2018 03:08:39 PM (3 years ago)
Author:
atimmer
Message:

Docs: Improve JSDoc for js/wp-emoji-loader.js.

Props nicollle, dfangstrom, Igorsch.
Fixes #43870.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/js/wp-emoji-loader.js

    r42602 r43143  
    22    var src, ready, ii, tests;
    33
    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.
    85    var canvas = document.createElement( 'canvas' );
    96    var context = canvas.getContext && canvas.getContext( '2d' );
    107
    118    /**
    12      * Check if two sets of Emoji characters render the same.
     9     * Checks if two sets of Emoji characters render the same visually.
    1310     *
    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.
    1719     */
    1820    function emojiSetsRenderIdentically( set1, set2 ) {
     
    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     * 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.
    3741     *
    3842     * @since 4.2.0
    3943     *
    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.
    4249     */
    4350    function browserSupportsEmoji( type ) {
     
    105112    }
    106113
     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     */
    107124    function addScript( src ) {
    108125        var script = document.createElement( 'script' );
     
    120137    };
    121138
     139    /*
     140     * Tests the browser support for flag emojis and other emojis, and adjusts the
     141     * support settings accordingly.
     142     */
    122143    for( ii = 0; ii < tests.length; ii++ ) {
    123144        settings.supports[ tests[ ii ] ] = browserSupportsEmoji( tests[ ii ] );
     
    132153    settings.supports.everythingExceptFlag = settings.supports.everythingExceptFlag && ! settings.supports.flag;
    133154
     155    // Sets DOMReady to false and assigns a ready function to settings.
    134156    settings.DOMReady = false;
    135157    settings.readyCallback = function() {
     
    137159    };
    138160
     161    // When the browser can not render everything we need to load a polyfill.
    139162    if ( ! settings.supports.everything ) {
    140163        ready = function() {
     
    142165        };
    143166
     167        /*
     168         * Cross-browser version of adding a dom ready event.
     169         */
    144170        if ( document.addEventListener ) {
    145171            document.addEventListener( 'DOMContentLoaded', ready, false );
Note: See TracChangeset for help on using the changeset viewer.