]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/wp-emoji-loader.js
Wordpress 4.6
[autoinstalls/wordpress.git] / wp-includes / js / wp-emoji-loader.js
index f242a12f2677bf5176312fb17c876a878002e969..ff73a885c91fd612b2f5eccbc205d9a647309ede 100644 (file)
@@ -14,7 +14,7 @@
                var canvas = document.createElement( 'canvas' ),
                        context = canvas.getContext && canvas.getContext( '2d' ),
                        stringFromCharCode = String.fromCharCode,
-                       tonedata, tone, tone2;
+                       flag, flag2, tonedata, tone, tone2;
 
                if ( ! context || ! context.fillText ) {
                        return false;
                                 * to a larger image (4-5KB data URL).
                                 */
                                context.fillText( stringFromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
-                               return canvas.toDataURL().length > 3000;
+                               if ( canvas.toDataURL().length < 3000 ) {
+                                       return false;
+                               }
+
+                               context.clearRect( 0, 0, canvas.width, canvas.height );
+
+                               /*
+                                * Test for rainbow flag compatibility. As the rainbow flag was added out of sequence with
+                                * the usual Unicode release cycle, some browsers support it, and some don't, even if their
+                                * Unicode support is up to date.
+                                *
+                                * To test for support, we try to render it, and compare the rendering to how it would look if
+                                * the browser doesn't render it correctly (white flag emoji + rainbow emoji).
+                                */
+                               context.fillText( stringFromCharCode( 55356, 57331, 65039, 8205, 55356, 57096 ), 0, 0 );
+                               flag = canvas.toDataURL();
+
+                               context.clearRect( 0, 0, canvas.width, canvas.height );
+
+                               context.fillText( stringFromCharCode( 55356, 57331, 55356, 57096 ), 0, 0 );
+                               flag2 = canvas.toDataURL();
+
+                               return flag !== flag2;
                        case 'diversity':
                                /*
                                 * This tests if the browser supports the Emoji Diversity specification, by rendering an
                                 */
                                context.fillText( stringFromCharCode( 55356, 57135 ), 0, 0 );
                                return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;
+                       case 'unicode9':
+                               /*
+                                * Do Unicode 9 emoji render?
+                                * ¯\_(ツ)_/¯
+                                */
+                               context.fillText( stringFromCharCode( 55358, 56631 ), 0, 0 );
+                               return context.getImageData( 16, 16, 1, 1 ).data[0] !== 0;
                }
 
                return false;
                document.getElementsByTagName( 'head' )[0].appendChild( script );
        }
 
-       tests = Array( 'simple', 'flag', 'unicode8', 'diversity' );
+       tests = Array( 'simple', 'flag', 'unicode8', 'diversity', 'unicode9' );
 
        settings.supports = {
                everything: true,