- if ( 'flag' === type ) {
- /*
- * This works because the image will be one of three things:
- * - Two empty squares, if the browser doesn't render emoji
- * - Two squares with 'A' and 'U' in them, if the browser doesn't render flag emoji
- * - The Australian flag
- *
- * The first two will encode to small images (1-2KB data URLs), the third will encode
- * to a larger image (4-5KB data URL).
- */
- context.fillText( String.fromCharCode( 55356, 56806, 55356, 56826 ), 0, 0 );
- return canvas.toDataURL().length > 3000;
- } else {
- if ( 'simple' === type ) {
+ switch ( type ) {
+ case 'flag':
+ /*
+ * This works because the image will be one of three things:
+ * - Two empty squares, if the browser doesn't render emoji
+ * - Two squares with 'U' and 'N' in them, if the browser doesn't render flag emoji
+ * - The United Nations flag
+ *
+ * The first two will encode to small images (1-2KB data URLs), the third will encode
+ * to a larger image (4-5KB data URL).
+ */
+ context.fillText( stringFromCharCode( 55356, 56826, 55356, 56819 ), 0, 0 );
+ if ( canvas.toDataURL().length < 3000 ) {
+ return false;
+ }
+
+ context.clearRect( 0, 0, canvas.width, canvas.height );
+