Repository navigation
[lexical-website] Documentation Update: document the full update-listener payload and the cascade guard - #9227
Merged
etrepum merged 1 commit intoSep 25, 2026
Conversation
potatowagon
requested review from
acywatson,
etrepum,
fantactuka,
ivailop7 and
zurfyx
as code owners
September 24, 2026 16:47
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
etrepum
reviewed
Sep 24, 2026
Comment on lines
+32
to
+49
| - `dirtyElements` a Map of the NodeKeys of ElementNodes that were marked | ||
| dirty, to a boolean that is true when the node was intentionally mutated | ||
| - `dirtyLeaves` a Set of the NodeKeys of all dirty nodes that are not | ||
| ElementNodes | ||
| - `mutatedNodes` a Map of LexicalNode constructors to a | ||
| `Map<NodeKey, NodeMutation>`, or null when no DOM was mutated. Only | ||
| populated when at least one MutationListener is registered | ||
| - `normalizedNodes` (advanced) the keys of TextNode descendants that were | ||
| merged with a sibling by normalization | ||
| - `dirtyElements` a Map of the NodeKeys of ElementNodes that were marked | ||
| dirty, to a boolean that is true when the node was intentionally mutated | ||
| - `dirtyLeaves` a Set of the NodeKeys of all dirty nodes that are not | ||
| ElementNodes | ||
| - `mutatedNodes` a Map of LexicalNode constructors to a | ||
| `Map<NodeKey, NodeMutation>`, or null when no DOM was mutated. Only | ||
| populated when at least one MutationListener is registered | ||
| - `normalizedNodes` (advanced) the keys of TextNode descendants that were | ||
| merged with a sibling by normalization |
Collaborator
There was a problem hiding this comment.
There are duplicate bullet points in here
Contributor
Author
There was a problem hiding this comment.
Good catch — thank you. That was a bug in how I generated the branch: the edit script ran twice over the same working tree, so each insertion landed twice. Force-pushed a rebuilt branch from main; the diff is now a single clean insertion (9 bullet lines + the cascade paragraph, no repeats).
Comment on lines
+78
to
+83
| A listener that re-enqueues work without a stop condition is worse than slow. | ||
| The editor keeps a cascade budget: once a run of updates re-enqueues more | ||
| than 100 times without yielding to the event loop, it discards the entire | ||
| pending update queue and warns. Bounded activity never reaches the limit — | ||
| the budget is reset from a macrotask, which a genuine runaway starves — but a | ||
| true loop silently loses whatever else was queued. |
Collaborator
There was a problem hiding this comment.
This is also a duplicate of the above
Contributor
Author
There was a problem hiding this comment.
Same cause as above — fixed in the force-push. Both the bullet list and the cascade paragraph now appear exactly once.
…ener payload and the cascade guard
## Description
Two gaps in `concepts/listeners.md`:
1. **The update-listener payload is listed as three properties** —
`editorState`, `prevEditorState`, `tags`. `UpdateListenerPayload` has
seven: `dirtyElements`, `dirtyLeaves`, `mutatedNodes` and
`normalizedNodes` are also passed, and a listener that wants to react to
*what* changed needs them.
2. **Waterfall updates are described as only a performance problem** — "two
DOM updates, when we likely could have done it in a single DOM update".
There is also a hard guard: past 100 cascading updates without yielding to
the event loop, the editor discards its entire pending update queue and
warns. A listener that re-enqueues in a loop therefore loses queued work
silently, which is not a performance characteristic. Nothing in the docs
tree mentions it.
Descriptions are taken from the doc comments on the payload interface.
## Test plan
Documentation-only change (markdown is excluded from prettier via
`.prettierignore`), so the check is that the documented payload matches the
type and that the guard exists.
### Before
```
$ sed -n '29,31p' packages/lexical-website/docs/concepts/listeners.md
- `editorState` the latest updated Editor State
- `prevEditorState` the previous Editor State
- `tags` a Set of all tags that were passed to the update
$ grep -n "^ [a-zA-Z]*:" packages/lexical/src/LexicalEditor.ts | sed -n '/546/,/598/p'
$ sed -n '546,598p' packages/lexical/src/LexicalEditor.ts | grep -n "^ [a-z]"
7: dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>;
12: dirtyLeaves: Set<NodeKey>;
17: editorState: EditorState;
29: mutatedNodes: null | MutatedNodes;
38: normalizedNodes: Set<NodeKey>;
42: prevEditorState: EditorState;
$ grep -rni "cascade" packages/lexical-website/docs/ | wc -l
0
$ grep -n "_cascadeCount++" packages/lexical/src/LexicalUpdates.ts
1026: if (editor._cascadeCount++ > 99) {
```
### After
```
$ sed -n '29,42p' packages/lexical-website/docs/concepts/listeners.md
- `editorState` the latest updated Editor State
- `prevEditorState` the previous Editor State
- `tags` a Set of all tags that were passed to the update
- `dirtyElements` a Map of the NodeKeys of ElementNodes that were marked
dirty, to a boolean that is true when the node was intentionally mutated
- `dirtyLeaves` a Set of the NodeKeys of all dirty nodes that are not
ElementNodes
- `mutatedNodes` a Map of LexicalNode constructors to a
`Map<NodeKey, NodeMutation>`, or null when no DOM was mutated. Only
populated when at least one MutationListener is registered
- `normalizedNodes` (advanced) the keys of TextNode descendants that were
merged with a sibling by normalization
$ grep -n "cascade budget" packages/lexical-website/docs/concepts/listeners.md
57:The editor keeps a cascade budget: once a run of updates re-enqueues more
```
The queue-clearing behaviour and the macrotask reset that keeps bounded
activity from reaching the limit are
`packages/lexical/src/LexicalUpdates.ts:991-1040`; the payload fields and
their descriptions are `packages/lexical/src/LexicalEditor.ts:546-598`.
potatowagon
force-pushed
the
docs-listeners-payload-and-cascade
branch
from
September 25, 2026 03:44
e73548a to
53b05bc
Compare
etrepum
approved these changes
Sep 25, 2026
Merged
This branch was successfully deployed
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
Two gaps in
concepts/listeners.md:editorState,prevEditorState,tags.UpdateListenerPayloadhasseven:
dirtyElements,dirtyLeaves,mutatedNodesandnormalizedNodesare also passed, and a listener that wants to react towhat changed needs them.
DOM updates, when we likely could have done it in a single DOM update".
There is also a hard guard: past 100 cascading updates without yielding to
the event loop, the editor discards its entire pending update queue and
warns. A listener that re-enqueues in a loop therefore loses queued work
silently, which is not a performance characteristic. Nothing in the docs
tree mentions it.
Descriptions are taken from the doc comments on the payload interface.
Test plan
Documentation-only change (markdown is excluded from prettier via
.prettierignore), so the check is that the documented payload matches thetype and that the guard exists.
Before
After
The queue-clearing behaviour and the macrotask reset that keeps bounded
activity from reaching the limit are
packages/lexical/src/LexicalUpdates.ts:991-1040; the payload fields andtheir descriptions are
packages/lexical/src/LexicalEditor.ts:546-598.