Make WordPress Core

Changeset 37090


Ignore:
Timestamp:
03/29/2016 02:18:51 AM (8 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.

Merge of [37028] to the 4.4 branch.

Fixes #36266.

File:
1 edited

Legend:

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

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