<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[31786] trunk/src: Emoji:</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/31786">31786</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/31786","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>azaozz</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-03-15 23:15:28 +0000 (Sun, 15 Mar 2015)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Emoji:
- Add the styling for the replacement images to the admin CSS.
- Revert to using `.emoji` as replacement image class.
- When pasting in the editor, convert emoji images to our format so we can replace them with chars on saving.
- Some more clean up of both the plugin and wp-emoji.js.
See <a href="https://core.trac.wordpress.org/ticket/31242">#31242</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadmincsscommoncss">trunk/src/wp-admin/css/common.css</a></li>
<li><a href="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesformattingphp">trunk/src/wp-includes/formatting.php</a></li>
<li><a href="#trunksrcwpincludesjstinymcepluginswpemojipluginjs">trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js</a></li>
<li><a href="#trunksrcwpincludesjstinymceskinswordpresswpcontentcss">trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css</a></li>
<li><a href="#trunksrcwpincludesjswpemojijs">trunk/src/wp-includes/js/wp-emoji.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadmincsscommoncss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/css/common.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/css/common.css 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-admin/css/common.css 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -679,6 +679,20 @@
</span><span class="cx" style="display: block; padding: 0 10px"> color: #999;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+/* For emoji replacement images */
+img.emoji {
+ display: inline !important;
+ border: none !important;
+ height: 1em !important;
+ width: 1em !important;
+ margin: 0 .07em !important;
+ vertical-align: -0.1em !important;
+ background: none !important;
+ padding: 0 !important;
+ -webkit-box-shadow: none !important;
+ box-shadow: none !important;
+}
+
</ins><span class="cx" style="display: block; padding: 0 10px"> /*------------------------------------------------------------------------------
</span><span class="cx" style="display: block; padding: 0 10px"> 1.0 - Text Styles
</span><span class="cx" style="display: block; padding: 0 10px"> ------------------------------------------------------------------------------*/
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-includes/default-filters.php 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -254,7 +254,6 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_print_scripts', 'print_head_scripts', 20 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_print_footer_scripts', '_wp_footer_scripts' );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'admin_print_styles', 'print_admin_styles', 20 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'admin_print_styles', 'print_emoji_styles' );
</del><span class="cx" style="display: block; padding: 0 10px"> add_action( 'init', 'smilies_init', 5 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'plugins_loaded', 'wp_maybe_load_widgets', 0 );
</span><span class="cx" style="display: block; padding: 0 10px"> add_action( 'plugins_loaded', 'wp_maybe_load_embeds', 0 );
</span></span></pre></div>
<a id="trunksrcwpincludesformattingphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/formatting.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/formatting.php 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-includes/formatting.php 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4046,7 +4046,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: none !important;
</span><span class="cx" style="display: block; padding: 0 10px"> height: 1em !important;
</span><span class="cx" style="display: block; padding: 0 10px"> width: 1em !important;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin: 0 .05em 0 .1em !important;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin: 0 .07em !important;
</ins><span class="cx" style="display: block; padding: 0 10px"> vertical-align: -0.1em !important;
</span><span class="cx" style="display: block; padding: 0 10px"> background: none !important;
</span><span class="cx" style="display: block; padding: 0 10px"> padding: 0 !important;
</span></span></pre></div>
<a id="trunksrcwpincludesjstinymcepluginswpemojipluginjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-includes/js/tinymce/plugins/wpemoji/plugin.js 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1,52 +1,76 @@
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-( function( tinymce, wp ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+( function( tinymce, wp, twemoji ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> tinymce.PluginManager.add( 'wpemoji', function( editor ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var typing,
</span><span class="cx" style="display: block; padding: 0 10px"> isMacWebKit = tinymce.Env.mac && tinymce.Env.webkit;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! wp || ! wp.emoji ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! wp || ! wp.emoji || ! wp.emoji.replaceEmoji ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function setImgAttr( image ) {
+ image.className = 'emoji';
+ image.setAttribute( 'data-mce-resize', 'false' );
+ image.setAttribute( 'data-mce-placeholder', '1' );
+ image.setAttribute( 'data-wp-emoji', image.alt );
+ }
+
+ function replaceEmoji( node ) {
+ wp.emoji.parse( node, { className: 'emoji _inserted-emoji' } );
+ tinymce.each( editor.dom.$( 'img._inserted-emoji', node ), setImgAttr );
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> editor.on( 'keydown keyup', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px"> typing = event.type === 'keydown';
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- editor.on( 'input setcontent', function( event ) {
- var selection, node, bookmark, images;
-
- if ( typing && event.type === 'input' ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.on( 'input', function( event ) {
+ if ( typing ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- selection = editor.selection;
- node = selection.getNode();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var bookmark,
+ selection = editor.selection,
+ node = selection.getNode();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isMacWebKit ) {
- bookmark = selection.getBookmark();
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( twemoji.test( node.textContent || node.innerText ) ) {
+ if ( isMacWebKit ) {
+ bookmark = selection.getBookmark();
+ }
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- wp.emoji.parse( node, { className: 'wp-emoji new-emoji' } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ replaceEmoji( node );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- images = editor.dom.select( 'img.new-emoji', node );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( isMacWebKit ) {
+ selection.moveToBookmark( bookmark );
+ }
+ }
+ });
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- tinymce.each( images, function( image ) {
- image.className = 'wp-emoji';
- image.setAttribute( 'data-mce-resize', 'false' );
- image.setAttribute( 'data-mce-placeholder', '1' );
- image.setAttribute( 'data-wp-emoji', image.alt );
- } );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ editor.on( 'setcontent', function( event ) {
+ var selection = editor.selection,
+ node = selection.getNode();
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- // In IE all content in the editor is left selected aftrer wp.emoji.parse()...
- // Collapse the selection to the beginning.
- if ( tinymce.Env.ie && node && node.nodeName === 'BODY' ) {
- selection.collapse( true );
- }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( twemoji.test( node.textContent || node.innerText ) ) {
+ replaceEmoji( node );
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( isMacWebKit ) {
- selection.moveToBookmark( bookmark );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // In IE all content in the editor is left selected aftrer wp.emoji.parse()...
+ // Collapse the selection to the beginning.
+ if ( tinymce.Env.ie && tinymce.Env.ie < 9 && event.load && node && node.nodeName === 'BODY' ) {
+ selection.collapse( true );
+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Convert Twemoji compatible pasted emoji repacement images into our format.
+ editor.on( 'PastePostProcess', function( event ) {
+ if ( twemoji ) {
+ tinymce.each( editor.dom.$( 'img.emoji', event.node ), function( image ) {
+ if ( image.alt && twemoji.test( image.alt ) ) {
+ setImgAttr( image );
+ }
+ });
+ }
+ });
+
</ins><span class="cx" style="display: block; padding: 0 10px"> editor.on( 'postprocess', function( event ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( event.content ) {
</span><span class="cx" style="display: block; padding: 0 10px"> event.content = event.content.replace( /<img[^>]+data-wp-emoji="([^"]+)"[^>]*>/g, function( match, emoji ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -61,4 +85,4 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-} )( window.tinymce, window.wp );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+} )( window.tinymce, window.wp, window.twemoji );
</ins></span></pre></div>
<a id="trunksrcwpincludesjstinymceskinswordpresswpcontentcss"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-includes/js/tinymce/skins/wordpress/wp-content.css 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -58,12 +58,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /* For emoji replacement images */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-img.wp-emoji {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+img.emoji {
+ display: inline !important;
+ border: none !important;
</ins><span class="cx" style="display: block; padding: 0 10px"> height: 1em !important;
</span><span class="cx" style="display: block; padding: 0 10px"> width: 1em !important;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- margin: 0 0.07em !important;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ margin: 0 .07em !important;
</ins><span class="cx" style="display: block; padding: 0 10px"> vertical-align: -0.1em !important;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- border: none !important;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ background: none !important;
</ins><span class="cx" style="display: block; padding: 0 10px"> padding: 0 !important;
</span><span class="cx" style="display: block; padding: 0 10px"> -webkit-box-shadow: none !important;
</span><span class="cx" style="display: block; padding: 0 10px"> box-shadow: none !important;
</span></span></pre></div>
<a id="trunksrcwpincludesjswpemojijs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/wp-emoji.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/wp-emoji.js 2015-03-15 20:00:57 UTC (rev 31785)
+++ trunk/src/wp-includes/js/wp-emoji.js 2015-03-15 23:15:28 UTC (rev 31786)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -4,31 +4,31 @@
</span><span class="cx" style="display: block; padding: 0 10px"> var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Flag to determine if we should parse all emoji characters into Twemoji images.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Flag to determine if the browser and the OS support emoji.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var Boolean
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- parseAllEmoji = false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ supportsEmoji = false,
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Flag to determine if we should consider parsing emoji characters into Twemoji images.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Flag to determine if the browser and the OS support flag (two character) emoji.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var Boolean
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- parseEmoji = false,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ supportsFlagEmoji = false,
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Flag to determine if we should parse flag characters into Twemoji images.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Flag to determine if we should replace emoji characters with images.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @var Boolean
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- parseFlags = false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ replaceEmoji = false;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Runs when the document load event is fired, so we can do our first parse of the page.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -39,8 +39,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> if ( MutationObserver ) {
</span><span class="cx" style="display: block; padding: 0 10px"> new MutationObserver( function( mutationRecords ) {
</span><span class="cx" style="display: block; padding: 0 10px"> var i = mutationRecords.length,
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- ii,
- node;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ ii, node;
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> while ( i-- ) {
</span><span class="cx" style="display: block; padding: 0 10px"> ii = mutationRecords[ i ].addedNodes.length;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -57,9 +56,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- } )
-
- .observe( document.body, {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } ).observe( document.body, {
</ins><span class="cx" style="display: block; padding: 0 10px"> childList: true,
</span><span class="cx" style="display: block; padding: 0 10px"> subtree: true
</span><span class="cx" style="display: block; padding: 0 10px"> } );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -74,7 +71,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param flagEmoji {Boolean} Whether to test for support of flag emoji.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param type {String} Whether to test for support of "simple" or "flag" emoji.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return {Boolean} True if the browser can render emoji, false if it cannot.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function browserSupportsEmoji( type ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -117,13 +114,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 4.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param {HTMLElement|String} object The element or string to parse.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param {Object} args Additional options for Twemoji.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- function parse( object, options ) {
- if ( ! parseEmoji ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function parse( object, args ) {
+ if ( ! replaceEmoji ) {
</ins><span class="cx" style="display: block; padding: 0 10px"> return object;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- var className = ( options && options.className ) || 'emoji';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ var className = ( args && args.className ) || 'emoji';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return twemoji.parse( object, {
</span><span class="cx" style="display: block; padding: 0 10px"> base: settings.baseUrl,
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -143,7 +141,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( parseFlags && ! parseAllEmoji &&
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! supportsFlagEmoji && supportsEmoji &&
</ins><span class="cx" style="display: block; padding: 0 10px"> ! /^1f1(?:e[6-9a-f]|f[1-9a-f])-1f1(?:e[6-9a-f]|f[1-9a-f])$/.test( icon ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -158,10 +156,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Initialize our emoji support, and set up listeners.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( twemoji && settings ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- parseAllEmoji = ! browserSupportsEmoji();
- parseFlags = ! browserSupportsEmoji( 'flag' );
- parseEmoji = parseAllEmoji || parseFlags;
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ supportsEmoji = browserSupportsEmoji();
+ supportsFlagEmoji = browserSupportsEmoji( 'flag' );
+ replaceEmoji = ! supportsEmoji || ! supportsFlagEmoji;
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( window.addEventListener ) {
</span><span class="cx" style="display: block; padding: 0 10px"> window.addEventListener( 'load', load, false );
</span><span class="cx" style="display: block; padding: 0 10px"> } else if ( window.attachEvent ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -171,6 +169,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return {
</span><span class="cx" style="display: block; padding: 0 10px"> browserSupportsEmoji: browserSupportsEmoji,
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ replaceEmoji: replaceEmoji,
</ins><span class="cx" style="display: block; padding: 0 10px"> parse: parse
</span><span class="cx" style="display: block; padding: 0 10px"> };
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre>
</div>
</div>
</body>
</html>