Make WordPress Core

Ticket #57301: 57301.diff

File 57301.diff, 1.6 KB (added by sergiomdgomes, 3 years ago)

Patch that fixes the issue, by having the emojiSetsRenderIdentically function expect code points

  • src/js/_enqueues/lib/emoji-loader.js

    diff --git a/src/js/_enqueues/lib/emoji-loader.js b/src/js/_enqueues/lib/emoji-loader.js
    index 0b5f3c7749..6cfe4ca9cd 100644
    a b  
    99        var canvas = document.createElement( 'canvas' );
    1010        var context = canvas.getContext && canvas.getContext( '2d' );
    1111
     12        // If the browser doesn't support String.fromCodePoint, assume that it doesn't
     13        // correctly support the latest emoji either.
     14        var supportsFromCodePoint = typeof String.fromCodePoint === 'function';
     15
    1216        /**
    1317         * Checks if two sets of Emoji characters render the same visually.
    1418         *
     
    2226         * @return {boolean} True if the two sets render the same.
    2327         */
    2428        function emojiSetsRenderIdentically( set1, set2 ) {
    25                 var stringFromCharCode = String.fromCharCode;
     29                var stringFromCodePoint = String.fromCodePoint;
    2630
    2731                // Cleanup from previous test.
    2832                context.clearRect( 0, 0, canvas.width, canvas.height );
    29                 context.fillText( stringFromCharCode.apply( this, set1 ), 0, 0 );
     33                context.fillText( stringFromCodePoint.apply( this, set1 ), 0, 0 );
    3034                var rendered1 = canvas.toDataURL();
    3135
    3236                // Cleanup from previous test.
    3337                context.clearRect( 0, 0, canvas.width, canvas.height );
    34                 context.fillText( stringFromCharCode.apply( this, set2 ), 0, 0 );
     38                context.fillText( stringFromCodePoint.apply( this, set2 ), 0, 0 );
    3539                var rendered2 = canvas.toDataURL();
    3640
    3741                return rendered1 === rendered2;
     
    5458        function browserSupportsEmoji( type ) {
    5559                var isIdentical;
    5660
    57                 if ( ! context || ! context.fillText ) {
     61                if ( ! context || ! context.fillText || ! supportsFromCodePoint ) {
    5862                        return false;
    5963                }
    6064