[Hot fix] Add null check to list metadata#1379
Merged
juliaroldi merged 4 commits intomasterfrom Nov 3, 2022
Merged
Conversation
7e6582b to
1b5e3fe
Compare
…u/juliaroldi/hot-fix-list-features
JiuqingSong
reviewed
Nov 3, 2022
| return previousNode && getTagOfNode(previousNode) === 'LI' | ||
| return previousNode && | ||
| getTagOfNode(previousNode) === 'LI' && | ||
| getMetadata(previousNode.parentElement, ListStyleDefinitionMetadata) |
Collaborator
There was a problem hiding this comment.
Do not call getMetadata twice. It is heavy
| return previousNode && getTagOfNode(previousNode) === 'LI' | ||
| return previousNode && | ||
| getTagOfNode(previousNode) === 'LI' && | ||
| getMetadata(previousNode.parentElement, ListStyleDefinitionMetadata) |
Contributor
There was a problem hiding this comment.
parentElement can be null, can we add a null check?
JiuqingSong
reviewed
Nov 3, 2022
| 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); |
Collaborator
There was a problem hiding this comment.
If previousNode or previousNode.parentElement is null, this will still be a problem.
BTW, what is the parent element here?
Contributor
Author
There was a problem hiding this comment.
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.
BryanValverdeU
approved these changes
Nov 3, 2022
JiuqingSong
approved these changes
Nov 3, 2022
juliaroldi
added a commit
that referenced
this pull request
Nov 3, 2022
…tures [Hot fix] Add null check to list metadata
BryanValverdeU
pushed a commit
that referenced
this pull request
Feb 10, 2023
…tures [Hot fix] Add null check to list metadata
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.
When the list does not have metadata, return previous list style as null.