WordPress.org

Make WordPress Core

Changeset 37028


Ignore:
Timestamp:
03/17/2016 04:53:49 AM (4 years ago)
Author:
pento
Message:

Emoji: Fix the diversity emoji check in Safari.

When the browser test for diversity emoji was added in [36160], it included a workaround for Chrome not being able to compare Uint8ClampedArray objects directly, by converting them to a string. Unfortunately, Safari doesn't support the Uint8ClampedArray.toString() method correctly, so the test was incorrectly failing in Safari.

Fixes #36266 for trunk.

File:
1 edited

Legend:

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

    r36816 r37028  
    1515            context = canvas.getContext && canvas.getContext( '2d' ),
    1616            stringFromCharCode = String.fromCharCode,
    17             tone;
     17            tonedata, tone, tone2;
    1818
    1919        if ( ! context || ! context.fillText ) {
     
    4949                 */
    5050                context.fillText( stringFromCharCode( 55356, 57221 ), 0, 0 );
    51                 tone = context.getImageData( 16, 16, 1, 1 ).data.toString();
     51                tonedata = context.getImageData( 16, 16, 1, 1 ).data;
     52
    5253                context.fillText( stringFromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
    53                 // Chrome has issues comparing arrays, so we compare it as a  string, instead.
    54                 return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();
     54                // Chrome has issues comparing arrays, and Safari has issues converting arrays to strings.
     55                // So, we create our own string and compare that, instead.
     56                tonedata = context.getImageData( 16, 16, 1, 1 ).data;
     57                tone2 = tonedata[0] + ',' + tonedata[1] + ',' + tonedata[2] + ',' + tonedata[3];
     58
     59                return tone !== tone2;
    5560            case 'simple':
    5661                /*
Note: See TracChangeset for help on using the changeset viewer.