Repository navigation
Conversation
…d to it
## Description
`EmojiNode` renders a wrapper span around the element `TextNode.createDOM` builds, and drops the format work that element carries in two places.
**`updateDOM` discards `super`'s return value.**
```ts
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
const inner = dom.firstChild;
if (inner === null) {
return true;
}
super.updateDOM(prevNode, inner as HTMLElement, config);
return false; // <- super may have returned true
}
```
`TextNode.updateDOM` returns `true` when the new format needs a different tag, and it does so *before touching the DOM*:
```ts
if (prevTag !== nextTag) {
return true;
}
```
`true` means "I could not apply this, recreate the element". `EmojiNode` throws that away and returns `false`, which promises the reconciler that every difference is already in the DOM — so nothing is recreated. Selecting a range that contains an emoji and pressing Ctrl+B formats the emoji (`$updateTextFormat` formats token nodes wholesale, and an `EmojiNode` is a token), the surrounding text goes bold, and the emoji does not. The editor state and `exportJSON`/`exportDOM` all say bold: what you see is not what you copy. Same for italic, code, highlight, subscript and superscript — every format that changes the tag. Underline and strikethrough happen to work, because they are applied as classes on the same tag.
The `if (inner === null) return true` line above shows the intent was already understood here; the `super` result is simply dropped.
**`createDOM` replaces the inner element's class name.**
```ts
const inner = super.createDOM(config);
inner.className = 'emoji-inner'; // <- discards theme.text classes
```
`TextNode.createDOM` applies `config.theme.text.*` to that element for the class-based formats. Assigning `className` throws them away, so an underlined or highlighted emoji comes back unstyled every time `createDOM` runs again — pasting it elsewhere, undo/redo across it, reloading a saved document, or receiving it over collab.
Both are fixed without changing the emoji's own markup: `updateDOM` now returns what `TextNode.updateDOM` returned, and `createDOM` uses `addClassNamesToElement` (as the sibling `SpecialTextNode` already does) so `.emoji-inner` is added to the theme classes rather than replacing them. The CSS selectors `.emoji` and `.emoji-inner` still match.
## Test plan
New unit test `packages/lexical-playground/__tests__/unit/EmojiNode.test.ts`, one case per defect.
### Before
```
❯ packages/lexical-playground/__tests__/unit/EmojiNode.test.ts (2 tests | 2 failed)
× renders a tag-changing format applied after the emoji exists
AssertionError: expected null not to be null // Object.is equality
× keeps the theme class of a class-only format on the inner element
AssertionError: expected [ 'emoji-inner' ] to deeply equal [ 'emoji-inner', 'theme-underline' ]
Test Files 1 failed (1)
Tests 2 failed (2)
```
### After
```
Test Files 1 passed (1)
Tests 2 passed (2)
```
Package suite is unchanged:
```
$ npx vitest run packages/lexical-playground
Test Files 18 passed (18)
Tests 273 passed (273)
```
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:15
|
@LeSingh1 is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
EmojiNoderenders a wrapper span around the elementTextNode.createDOMbuilds, and drops the format work that element carries in two places.updateDOMdiscardssuper's return value.TextNode.updateDOMreturnstruewhen the new format needs a different tag, and it does so before touching the DOM:truemeans "I could not apply this, recreate the element".EmojiNodethrows that away and returnsfalse, which promises the reconciler that every difference is already in the DOM — so nothing is recreated. Selecting a range that contains an emoji and pressing Ctrl+B formats the emoji ($updateTextFormatformats token nodes wholesale, and anEmojiNodeis a token), the surrounding text goes bold, and the emoji does not. The editor state andexportJSON/exportDOMall say bold: what you see is not what you copy. Same for italic, code, highlight, subscript and superscript — every format that changes the tag. Underline and strikethrough happen to work, because they are applied as classes on the same tag.The
if (inner === null) return trueline above shows the intent was already understood here; thesuperresult is simply dropped.createDOMreplaces the inner element's class name.TextNode.createDOMappliesconfig.theme.text.*to that element for the class-based formats. AssigningclassNamethrows them away, so an underlined or highlighted emoji comes back unstyled every timecreateDOMruns again — pasting it elsewhere, undo/redo across it, reloading a saved document, or receiving it over collab.Both are fixed without changing the emoji's own markup:
updateDOMnow returns whatTextNode.updateDOMreturned, andcreateDOMusesaddClassNamesToElement(as the siblingSpecialTextNodealready does) so.emoji-inneris added to the theme classes rather than replacing them. The CSS selectors.emojiand.emoji-innerstill match.Test plan
New unit test
packages/lexical-playground/__tests__/unit/EmojiNode.test.ts, one case per defect.Before
After
Package suite is unchanged: