Skip to content

Commit

Permalink
fix(Slate) Does not fail on no children anymore (including empty list…
Browse files Browse the repository at this point in the history
… items)

Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Nov 13, 2019
1 parent 9b2816a commit 78bda61
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/markdown-slate/src/ToSlateVisitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class ToSlateVisitor {
processChildNodes(thing) {
const result = [];
if(!thing.nodes) {
throw new Error(`Node ${thing.getType()} doesn't have any children!`);
thing.nodes = []; // Treat no nodes as empty array of nods
}

thing.nodes.forEach(node => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2098,6 +2098,10 @@ Object {
},
],
},
Object {
"$class": "org.accordproject.commonmark.Item",
"nodes": Array [],
},
],
"start": undefined,
"tight": "true",
Expand Down Expand Up @@ -2131,6 +2135,7 @@ exports[`slate converts nested-list.json to and from CiceroMark 2`] = `
- sublist
- sublist
with some text in the same paragraph
-
Epilog
"
Expand Down Expand Up @@ -2250,6 +2255,12 @@ Object {
"object": "block",
"type": "list_item",
},
Object {
"data": Object {},
"nodes": Array [],
"object": "block",
"type": "list_item",
},
],
"object": "block",
"type": "ul_list",
Expand Down Expand Up @@ -2363,6 +2374,10 @@ Object {
},
],
},
Object {
"$class": "org.accordproject.commonmark.Item",
"nodes": Array [],
},
],
"start": undefined,
"tight": "true",
Expand Down
6 changes: 6 additions & 0 deletions packages/markdown-slate/test/data/nested-list.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@
]
}
]
},
{
"object": "block",
"type": "list_item",
"data": {},
"nodes": []
}
]
}
Expand Down
1 change: 1 addition & 0 deletions packages/markdown-slate/test/data/nested-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ Prolog
- sublist
- sublist
with some text in the same paragraph
-

Epilog

0 comments on commit 78bda61

Please sign in to comment.