From e736153adfdf42c0634db8b2a122ae7529e2391d Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Thu, 3 Mar 2016 05:20:19 +0000 Subject: [PATCH] Emoji: Add some extra IE11 compatibility. IE 11's implementation of MutationObserver is buggy. It unnecessarily splits text nodes when it encounters a HTML template interpolation symbol ( "{{", for example ). So, we join the text nodes back together as a work-around. Fixes #35977 for trunk. git-svn-id: https://develop.svn.wordpress.org/trunk@36817 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/js/wp-emoji.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/js/wp-emoji.js b/src/wp-includes/js/wp-emoji.js index 72a3b90910..2da0d014da 100644 --- a/src/wp-includes/js/wp-emoji.js +++ b/src/wp-includes/js/wp-emoji.js @@ -15,7 +15,8 @@ // Private twemoji, timer, loaded = false, - count = 0; + count = 0, + ie11 = window.navigator.userAgent.indexOf( 'Trident/7.0' ) > 0; /** * Runs when the document load event is fired, so we can do our first parse of the page. @@ -68,6 +69,23 @@ node = addedNodes[ ii ]; if ( node.nodeType === 3 ) { + if ( ! node.parentNode ) { + continue; + } + + if ( ie11 ) { + /* + * IE 11's implementation of MutationObserver is buggy. + * It unnecessarily splits text nodes when it encounters a HTML + * template interpolation symbol ( "{{", for example ). So, we + * join the text nodes back together as a work-around. + */ + while( node.nextSibling && 3 === node.nextSibling.nodeType ) { + node.nodeValue = node.nodeValue + node.nextSibling.nodeValue; + node.parentNode.removedChild( node.nextSibling ); + } + } + node = node.parentNode; }