diff --git a/src/wp-includes/js/twemoji.js b/src/wp-includes/js/twemoji.js index a80cd453c3..217ea71180 100644 --- a/src/wp-includes/js/twemoji.js +++ b/src/wp-includes/js/twemoji.js @@ -1,6 +1,5 @@ /*jslint indent: 2, browser: true, bitwise: true, plusplus: true */ -var twemoji; -twemoji = (function ( +var twemoji = (function ( /*! Copyright Twitter Inc. and other contributors. Licensed under MIT *//* https://github.com/twitter/twemoji/blob/gh-pages/LICENSE */ @@ -327,6 +326,7 @@ twemoji = (function ( var allText = grabAllTextNodes(node, []), length = allText.length, + modified = false, fragment, subnode, text, @@ -367,13 +367,15 @@ twemoji = (function ( img.setAttribute('draggable', 'false'); img.alt = alt; img.src = src; + modified = true; + fragment.appendChild(img); } } - fragment.appendChild(img || createText(alt)); + if (!img) fragment.appendChild(createText(alt)); + img = null; } // is there actually anything to replace in here ? - if (img) { - img = null; + if (modified) { // any text left to be added ? if (i < text.length) { fragment.appendChild( @@ -383,6 +385,7 @@ twemoji = (function ( // replace the text node only, leave intact // anything else surrounding such text subnode.parentNode.replaceChild(fragment, subnode); + modified = false; } } return node; diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 7bd909698b..c1bd357662 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -424,7 +424,7 @@ function wp_default_scripts( &$scripts ) { $scripts->add( 'media-audiovideo', "/wp-includes/js/media/audio-video$suffix.js", array( 'media-editor' ), false, 1 ); $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 ); - $scripts->add( 'twemoji', "/wp-includes/js/twemoji$suffix.js", array(), false, 1 ); + $scripts->add( 'twemoji', "/wp-includes/js/twemoji$suffix.js", array(), '1.3.0', 1 ); $scripts->add( 'emoji', "/wp-includes/js/wp-emoji$suffix.js", array( 'twemoji' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'emoji', '_wpemojiSettings', array( /**