Make WordPress Core

Opened 21 months ago

Last modified 2 months ago

#52219 new defect (bug)

wp-emoji.js should always skip nodes with the `wp-exclude-emoji` CSS class

Reported by: georgejipa's profile GeorgeJipa Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 4.2.2
Component: Emoji Keywords:
Focuses: javascript Cc:

Description

I just discovered it only happens only if the node is added later to the DOM.

Change History (1)

#1 @dd32
2 months ago

  • Version changed from 5.6 to 4.2.2

Relevant code: https://core.trac.wordpress.org/browser/trunk/src/js/_enqueues/wp/emoji.js?marks=148-170#L140

The only place the wp-exclude-emoji class is checked is within the MutationObserver, which is only called for DOM insertions. It appears that this is probably intentional, based on the original implementation via #32197

parse( document.body ) causes Twemoji to process every textnode, and the callback presented provides no context as to what element it's operating on - so we can't even return false there (to cause it to generate no img replacement).

The reference below to twemoji.parentNode gave me hope, but this appears not to be set anywhere I can find (either while debugging, or looking at the twemoji source).

I suspect this is going to require an upstream bug report to allow some form of context to be made available to the callback, so that we can return a falsey value here to abort the replacement.

Setting version to 4.2.2, as it appears this has always been how this functionality works.

Note: See TracTickets for help on using tickets.