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
This commit is contained in:
Gary Pendergast 2016-03-03 05:20:19 +00:00
parent 637ea44652
commit e736153adf
1 changed files with 19 additions and 1 deletions

View File

@ -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;
}