Skip to content

Commit

Permalink
[Lexical] Chore: Update default skipInitialization to false for regis…
Browse files Browse the repository at this point in the history
…terMutationListener (#6857)
  • Loading branch information
Shopiley authored Nov 23, 2024
1 parent fe4f5b8 commit d9014f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/lexical-website/docs/concepts/listeners.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ handle external UI state and UI features relating to specific types of node.
If any existing nodes are in the DOM, and skipInitialization is not true, the listener
will be called immediately with an updateTag of 'registerMutationListener' where all
nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option
(default is currently true for backwards compatibility in 0.17.x but will change to false in 0.18.0).
(whose default was previously true for backwards compatibility with <=0.16.1 but has been changed to false as of 0.21.0).

```js
const removeMutationListener = editor.registerMutationListener(
Expand Down
8 changes: 4 additions & 4 deletions packages/lexical/src/LexicalEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,13 +216,13 @@ export interface MutationListenerOptions {
/**
* Skip the initial call of the listener with pre-existing DOM nodes.
*
* The default is currently true for backwards compatibility with <= 0.16.1
* but this default is expected to change to false in 0.17.0.
* The default was previously true for backwards compatibility with <= 0.16.1
* but this default has been changed to false as of 0.21.0.
*/
skipInitialization?: boolean;
}

const DEFAULT_SKIP_INITIALIZATION = true;
const DEFAULT_SKIP_INITIALIZATION = false;

export type UpdateListener = (arg0: {
dirtyElements: Map<NodeKey, IntentionallyMarkedAsDirtyElement>;
Expand Down Expand Up @@ -844,7 +844,7 @@ export class LexicalEditor {
* If any existing nodes are in the DOM, and skipInitialization is not true, the listener
* will be called immediately with an updateTag of 'registerMutationListener' where all
* nodes have the 'created' NodeMutation. This can be controlled with the skipInitialization option
* (default is currently true for backwards compatibility in 0.16.x but will change to false in 0.17.0).
* (whose default was previously true for backwards compatibility with &lt;=0.16.1 but has been changed to false as of 0.21.0).
*
* @param klass - The class of the node that you want to listen to mutations on.
* @param listener - The logic you want to run when the node is mutated.
Expand Down

0 comments on commit d9014f3

Please sign in to comment.