Skip to content

Commit be6300a

Browse files
committed
fix(slate) Make sure the Slate DOM is a tree (not sharing empty text nodes)
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 5ed4a72 commit be6300a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/markdown-slate/src/ToSlateVisitor.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ class ToSlateVisitor {
341341

342342
// Cleanup block node for Slate
343343
if (result.object === 'block' || result.object === 'inline') {
344-
const bufferText = { object: 'text', text: '' };
344+
const emptyText = () => { return { object: 'text', text: '' }; };
345345
if (!result.data) {
346346
result.data = {};
347347
}
348348
if (!result.children || result.children.length === 0) {
349-
result.children = [ bufferText ];
349+
result.children = [ emptyText() ];
350350
}
351351
if (result.children && result.children.length > 0) {
352352
const normalizedChildren = [];
@@ -359,9 +359,9 @@ class ToSlateVisitor {
359359
normalizedChildren.length === 0 ||
360360
normalizedChildren[normalizedChildren.length - 1].object === 'inline'
361361
) {
362-
normalizedChildren.push(bufferText, child);
362+
normalizedChildren.push(emptyText(), child);
363363
} else if (isLast) {
364-
normalizedChildren.push(child, bufferText);
364+
normalizedChildren.push(child, emptyText());
365365
} else {
366366
normalizedChildren.push(child);
367367
}

0 commit comments

Comments
 (0)