Skip to content

Commit

Permalink
some internal field being assigned null
Browse files Browse the repository at this point in the history
  • Loading branch information
2wheeh committed Apr 23, 2024
1 parent 3874153 commit 07ef7d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/lexical-react/src/LexicalCheckListPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,8 @@ function findEditor(target: Node) {
// @ts-ignore internal field
if (node.__lexicalEditor) {
// @ts-ignore internal field
const editor: LexicalEditor | undefined = node.__lexicalEditor;
if (editor === undefined) {
const editor: LexicalEditor | undefined | null = node.__lexicalEditor;
if (editor === undefined || editor === null) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/lexical/src/LexicalReconciler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ function createNode(
// @ts-expect-error: internal field
const possibleLineBreak = parentDOM.__lexicalLineBreak;

if (possibleLineBreak !== undefined) {
if (possibleLineBreak !== undefined && possibleLineBreak !== null) {
parentDOM.insertBefore(dom, possibleLineBreak);
} else {
parentDOM.appendChild(dom);
Expand Down
11 changes: 7 additions & 4 deletions packages/lexical/src/LexicalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export function isSelectionCapturedInDecoratorInput(anchorDOM: Node): boolean {
nodeName === 'TEXTAREA' ||
(activeElement.contentEditable === 'true' &&
// @ts-ignore iternal field
activeElement.__lexicalEditor === undefined))
(activeElement.__lexicalEditor === undefined ||
// @ts-ignore iternal field
activeElement.__lexicalEditor === null)))
);
}

Expand Down Expand Up @@ -152,9 +154,10 @@ export function getNearestEditorFromDOMNode(
): LexicalEditor | null {
let currentNode = node;
while (currentNode !== null) {
// @ts-expect-error: internal field
const editor: LexicalEditor | undefined = currentNode.__lexicalEditor;
if (editor !== undefined) {
const editor: LexicalEditor | undefined | null =
// @ts-expect-error: internal field
currentNode.__lexicalEditor;
if (editor !== undefined && editor !== null) {
return editor;
}
currentNode = getParentElement(currentNode);
Expand Down

0 comments on commit 07ef7d7

Please sign in to comment.