diff --git a/src/record/mutation.ts b/src/record/mutation.ts index e11ffca0..c1e29134 100644 --- a/src/record/mutation.ts +++ b/src/record/mutation.ts @@ -216,7 +216,10 @@ export default class MutationBuffer { m.removedNodes.forEach((n) => { const nodeId = mirror.getId(n as INode); const parentId = mirror.getId(m.target as INode); - if (isBlocked(n, this.blockClass)) { + if ( + isBlocked(n, this.blockClass) || + isBlocked(m.target, this.blockClass) + ) { return; } // removed node has not been serialized yet, just remove it from the Set diff --git a/src/utils.ts b/src/utils.ts index f924fc0b..93d5ff58 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -189,6 +189,10 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean { } return needBlock || isBlocked(node.parentNode, blockClass); } + if (node.nodeType === node.TEXT_NODE) { + // check parent node since text node do not have class name + return isBlocked(node.parentNode, blockClass); + } return isBlocked(node.parentNode, blockClass); }