Skip to content

Commit

Permalink
Use firstChild and lastChild when parsing lists from MS Word (#36019)
Browse files Browse the repository at this point in the history
* Use firstChild due to lack of firstElementChild in React Native editor project.

* Use lastChild due to lack of lastElementChild in React Native editor project.
  • Loading branch information
twstokes committed Nov 10, 2021
1 parent 8d49077 commit 1dc8d6d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/blocks/src/api/raw-handling/ms-list-converter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export default function msListConverter( node, doc ) {
let receivingNode = listNode;

// Remove the first span with list info.
node.removeChild( node.firstElementChild );
node.removeChild( node.firstChild );

// Add content.
while ( node.firstChild ) {
Expand All @@ -63,11 +63,11 @@ export default function msListConverter( node, doc ) {

// Change pointer depending on indentation level.
while ( level-- ) {
receivingNode = receivingNode.lastElementChild || receivingNode;
receivingNode = receivingNode.lastChild || receivingNode;

// If it's a list, move pointer to the last item.
if ( isList( receivingNode ) ) {
receivingNode = receivingNode.lastElementChild || receivingNode;
receivingNode = receivingNode.lastChild || receivingNode;
}
}

Expand Down

0 comments on commit 1dc8d6d

Please sign in to comment.