Skip to content
Permalink
Browse files

Emoji: Stop emoji replacement from happening inside CodeMirror instan…

…ces, and clean up some logic in the `MutationObserver`.

Props pento, hirofumi2012, davidbaumwald.
Fixes #46537.

git-svn-id: https://develop.svn.wordpress.org/trunk@46393 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Oct 4, 2019
1 parent 0e2b212 commit c411aad31b1ce6be95836514b184d91e368fb32d
Showing with 7 additions and 8 deletions.
  1. +7 −8 src/js/_enqueues/wp/emoji.js
@@ -121,6 +121,11 @@
while ( ii-- ) {
node = addedNodes[ ii ];

// Don't replace emoji inside elements that don't support it.
if ( ! node || node.closest( '.wp-exclude-emoji' ) || node.closest( '.CodeMirror' ) ) {
continue;
}

// Node type 3 is a TEXT_NODE.
if ( node.nodeType === 3 ) {
if ( ! node.parentNode ) {
@@ -145,14 +150,8 @@
node = node.parentNode;
}

/*
* If the class name of a non-element node contains 'wp-exclude-emoji' ignore it.
*
* Node type 1 is an ELEMENT_NODE.
*/
if ( ! node || node.nodeType !== 1 ||
( node.className && typeof node.className === 'string' && node.className.indexOf( 'wp-exclude-emoji' ) !== -1 ) ) {

// Only make replacements inside Element nodes.
if ( node.nodeType !== 1 ) {
continue;
}

0 comments on commit c411aad

Please sign in to comment.
You can’t perform that action at this time.