From 35eae1c5ba7bdb56eca08a1b5d42f771b23c080f Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Sun, 12 May 2024 23:12:04 +0530 Subject: [PATCH] refactor implementation --- packages/lexical-list/src/LexicalListItemNode.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/lexical-list/src/LexicalListItemNode.ts b/packages/lexical-list/src/LexicalListItemNode.ts index ca9b8013508..c2c20dcf646 100644 --- a/packages/lexical-list/src/LexicalListItemNode.ts +++ b/packages/lexical-list/src/LexicalListItemNode.ts @@ -6,7 +6,7 @@ * */ -import type {ListNode} from './'; +import type {ListNode, ListType} from './'; import type { BaseSelection, DOMConversionMap, @@ -321,11 +321,12 @@ export class ListItemNode extends ElementNode { getChecked(): boolean | undefined { const self = this.getLatest(); + let listType: ListType | undefined; + const parent = this.getParent(); - if (!$isListNode(parent)) { - invariant(false, 'getChecked: list node is not parent of list item node'); + if ($isListNode(parent)) { + listType = parent.getListType(); } - const listType = parent.getListType(); return listType === 'check' ? Boolean(self.__checked) : undefined; }