]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/wp-emoji-loader.js
WordPress 4.4.1-scripts
[autoinstalls/wordpress.git] / wp-includes / js / wp-emoji-loader.js
index a495f3552b847899b66b96ff2ff49fcd05729367..327f66a19b913c4fab69961ed776ff3dd7cf1827 100644 (file)
@@ -12,7 +12,8 @@
         */
        function browserSupportsEmoji( type ) {
                var canvas = document.createElement( 'canvas' ),
-                       context = canvas.getContext && canvas.getContext( '2d' );
+                       context = canvas.getContext && canvas.getContext( '2d' ),
+                       tone;
 
                if ( ! context || ! context.fillText ) {
                        return false;
                         */
                        context.fillText( String.fromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
                        return canvas.toDataURL().length > 3000;
+               } else if ( 'diversity' === type ) {
+                       /*
+                        * This tests if the browser supports the Emoji Diversity specification, by rendering an
+                        * emoji with no skin tone specified (in this case, Santa). It then adds a skin tone, and
+                        * compares if the emoji rendering has changed.
+                        */
+                       context.fillText( String.fromCharCode( 55356, 57221 ), 0, 0 );
+                       tone = context.getImageData( 16, 16, 1, 1 ).data.toString();
+                       context.fillText( String.fromCharCode( 55356, 57221, 55356, 57343 ), 0, 0 );
+                       // Chrome has issues comparing arrays, so we compare it as a  string, instead.
+                       return tone !== context.getImageData( 16, 16, 1, 1 ).data.toString();
                } else {
                        if ( 'simple' === type ) {
                                /*
        }
 
        settings.supports = {
-               simple:   browserSupportsEmoji( 'simple' ),
-               flag:     browserSupportsEmoji( 'flag' ),
-               unicode8: browserSupportsEmoji( 'unicode8' )
+               simple:    browserSupportsEmoji( 'simple' ),
+               flag:      browserSupportsEmoji( 'flag' ),
+               unicode8:  browserSupportsEmoji( 'unicode8' ),
+               diversity: browserSupportsEmoji( 'diversity' )
        };
 
        settings.DOMReady = false;
@@ -76,7 +89,7 @@
                settings.DOMReady = true;
        };
 
-       if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 ) {
+       if ( ! settings.supports.simple || ! settings.supports.flag || ! settings.supports.unicode8 || ! settings.supports.diversity ) {
                ready = function() {
                        settings.readyCallback();
                };