Make WordPress Core

Changeset 46393


Ignore:
Timestamp:
10/04/2019 11:28:22 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Emoji: Stop emoji replacement from happening inside CodeMirror instances, and clean up some logic in the MutationObserver.

Props pento, hirofumi2012, davidbaumwald.
Fixes #46537.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/wp/emoji.js

    r45726 r46393  
    122122                                                        node = addedNodes[ ii ];
    123123
     124                                                        // Don't replace emoji inside elements that don't support it.
     125                                                        if ( ! node || node.closest( '.wp-exclude-emoji' ) || node.closest( '.CodeMirror' ) ) {
     126                                                                continue;
     127                                                        }
     128
    124129                                                        // Node type 3 is a TEXT_NODE.
    125130                                                        if ( node.nodeType === 3 ) {
     
    146151                                                        }
    147152
    148                                                         /*
    149                                                          * If the class name of a non-element node contains 'wp-exclude-emoji' ignore it.
    150                                                          *
    151                                                          * Node type 1 is an ELEMENT_NODE.
    152                                                          */
    153                                                         if ( ! node || node.nodeType !== 1 ||
    154                                                                 ( node.className && typeof node.className === 'string' && node.className.indexOf( 'wp-exclude-emoji' ) !== -1 ) ) {
    155 
     153                                                        // Only make replacements inside Element nodes.
     154                                                        if ( node.nodeType !== 1 ) {
    156155                                                                continue;
    157156                                                        }
Note: See TracChangeset for help on using the changeset viewer.