-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Hot fix] Add null check to list metadata #1379
Conversation
7e6582b
to
1b5e3fe
Compare
…u/juliaroldi/hot-fix-list-features
return previousNode && getTagOfNode(previousNode) === 'LI' | ||
return previousNode && | ||
getTagOfNode(previousNode) === 'LI' && | ||
getMetadata(previousNode.parentElement, ListStyleDefinitionMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not call getMetadata twice. It is heavy
return previousNode && getTagOfNode(previousNode) === 'LI' | ||
return previousNode && | ||
getTagOfNode(previousNode) === 'LI' && | ||
getMetadata(previousNode.parentElement, ListStyleDefinitionMetadata) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parentElement can be null, can we add a null check?
@@ -339,10 +339,9 @@ const getPreviousList = (editor: IEditor, textRange: Range) => { | |||
const getPreviousListType = (editor: IEditor, textRange: Range, listType: ListType) => { | |||
const type = listType === ListType.Ordered ? 'orderedStyleType' : 'unorderedStyleType'; | |||
const previousNode = getPreviousList(editor, textRange); | |||
const metadata = getMetadata(previousNode.parentElement, ListStyleDefinitionMetadata); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If previousNode or previousNode.parentElement is null, this will still be a problem.
BTW, what is the parent element here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should to be the UL or OL element, but I noticed that the list structure can different to just <ol><li></li><ol>
, then I changed the code to use findClosestElementAntecesor to find the ul or ol element that contain the metadata.
…tures [Hot fix] Add null check to list metadata
…tures [Hot fix] Add null check to list metadata
When the list does not have metadata, return previous list style as null.