Repository navigation
Conversation
…createDOM rendered
## Description
`RubyNode` wraps the element `TextNode.createDOM` builds, and `createDOM` is careful to keep everything super produced on the **inner** element:
```ts
createDOM(config: EditorConfig): HTMLElement {
const inner = super.createDOM(config); // theme.text.* classes + this.__style land here
inner.dataset.rubyAnnotation = this.getAnnotation();
addClassNamesToElement(inner, config.theme.ruby || 'PlaygroundEditorTheme__ruby');
const wrapper = $getDocument().createElement('span');
...
wrapper.appendChild(inner);
return wrapper; // the keyed element is the wrapper
}
```
`updateDOM` then hands super the **wrapper**:
```ts
updateDOM(prevNode: this, dom: HTMLElement, config: EditorConfig): boolean {
const updated = super.updateDOM(prevNode, dom, config); // dom === wrapper
```
The text itself survives, because the `getDOMSlot` override redirects `$setTextContent` to `dom.firstElementChild`. The other two things `TextNode.updateDOM` does bypass the slot and write to the element they were handed:
- `setTextThemeClassNames(..., innerDOM, textClassNames)`
- `setDOMStyleFromCSS(dom.style, nextStyle, prevStyle)`
So the two methods disagree about which element carries the formatting, and `updateDOM` returns `false` — promising the reconciler the DOM is already correct.
Rendered on `upstream/main`, a ruby node with `color: red` restyled to `color: blue` and underlined:
```html
<!-- after createDOM -->
<span role="group" aria-label="kanji (kana)">
<span style="color: red;" data-ruby-annotation="kana" class="theme-ruby">kanji</span>
</span>
<!-- after updateDOM -->
<span role="group" aria-label="kanji (kana)" class="theme-underline" style="color: blue;">
<span style="color: red;" data-ruby-annotation="kana" class="theme-ruby">kanji</span>
</span>
```
The inner element's own inline `color: red` still wins over the wrapper's `color: blue`, so **changing the colour of a ruby annotation does nothing** — the toolbar swatch moves and the text stays red. Underline and strikethrough land on the wrapper, whose only child is `.PlaygroundEditorTheme__ruby` with `display: inline-block`; text decoration does not propagate into an atomic inline box, so they are not painted either. Removing a format that was carried in from the original text (`$toggleRuby` copies `format` and `style` from the source node) strips the class from the wrapper while the inner keeps it, so the formatting can never be turned off.
Bold, italic, code, highlight, subscript and superscript are unaffected — those change the HTML tag, so `TextNode.updateDOM` returns `true` before touching the DOM and the node is rebuilt through `createDOM`. Only the formats applied in place are broken, which is why this looks arbitrary in use.
The fix resolves the inner element and passes it to super, exactly as `createDOM` and `getDOMSlot` already do. The wrapper keeps the `role`/`aria-label` it owns. When the inner is missing, `updateDOM` returns `true` so the reconciler rebuilds rather than silently promising a DOM it could not update.
## Test plan
New unit test `packages/lexical-playground/__tests__/unit/RubyNode.test.ts`. The first two cases assert the invariant `updateDOM` returning `false` actually promises: the DOM after mutating a node must equal the DOM of a freshly created node in the same state. That pins the assertion to `createDOM` rather than to a hardcoded expectation. The third case is a control covering the annotation and accessible name the wrapper legitimately owns, and passes before and after.
### Before
```
❯ packages/lexical-playground/__tests__/unit/RubyNode.test.ts (3 tests | 2 failed)
× applies a style change to the element createDOM styled
"innerClass": "theme-ruby",
- "innerStyle": "color: blue;",
+ "innerStyle": "color: red;",
"wrapperClass": "",
- "wrapperStyle": "",
+ "wrapperStyle": "color: blue;",
× applies a class-only text format to the element createDOM classed
- "innerClass": "theme-ruby theme-underline",
+ "innerClass": "theme-ruby",
"innerStyle": "color: red;",
- "wrapperClass": "",
+ "wrapperClass": "theme-underline",
✓ leaves the annotation and the accessible name on the wrapper
Test Files 1 failed (1)
Tests 2 failed | 1 passed (3)
```
### After
```
Test Files 1 passed (1)
Tests 3 passed (3)
```
Package suite is unchanged:
```
$ npx vitest run packages/lexical-playground
Test Files 19 passed (19)
Tests 277 passed (277)
```
LeSingh1
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7,
potatowagon and
zurfyx
as code owners
August 9, 2026 05:52
|
@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
RubyNodewraps the elementTextNode.createDOMbuilds, andcreateDOMis careful to keep everything super produced on the inner element:updateDOMthen hands super the wrapper:The text itself survives, because the
getDOMSlotoverride redirects$setTextContenttodom.firstElementChild. The other two thingsTextNode.updateDOMdoes bypass the slot and write to the element they were handed:setTextThemeClassNames(..., innerDOM, textClassNames)setDOMStyleFromCSS(dom.style, nextStyle, prevStyle)So the two methods disagree about which element carries the formatting, and
updateDOMreturnsfalse— promising the reconciler the DOM is already correct.Rendered on
upstream/main, a ruby node withcolor: redrestyled tocolor: blueand underlined:The inner element's own inline
color: redstill wins over the wrapper'scolor: blue, so changing the colour of a ruby annotation does nothing — the toolbar swatch moves and the text stays red. Underline and strikethrough land on the wrapper, whose only child is.PlaygroundEditorTheme__rubywithdisplay: inline-block; text decoration does not propagate into an atomic inline box, so they are not painted either. Removing a format that was carried in from the original text ($toggleRubycopiesformatandstylefrom the source node) strips the class from the wrapper while the inner keeps it, so the formatting can never be turned off.Bold, italic, code, highlight, subscript and superscript are unaffected — those change the HTML tag, so
TextNode.updateDOMreturnstruebefore touching the DOM and the node is rebuilt throughcreateDOM. Only the formats applied in place are broken, which is why this looks arbitrary in use.The fix resolves the inner element and passes it to super, exactly as
createDOMandgetDOMSlotalready do. The wrapper keeps therole/aria-labelit owns. When the inner is missing,updateDOMreturnstrueso the reconciler rebuilds rather than silently promising a DOM it could not update.Test plan
New unit test
packages/lexical-playground/__tests__/unit/RubyNode.test.ts. The first two cases assert the invariantupdateDOMreturningfalseactually promises: the DOM after mutating a node must equal the DOM of a freshly created node in the same state. That pins the assertion tocreateDOMrather than to a hardcoded expectation. The third case is a control covering the annotation and accessible name the wrapper legitimately owns, and passes before and after.Before
After
Package suite is unchanged: