filter text and attributes mutations which target tot a removed node
This commit is contained in:
@@ -154,14 +154,20 @@ function initMutationObserver(cb: mutationCallBack): MutationObserver {
|
||||
});
|
||||
|
||||
cb({
|
||||
texts: texts.map(text => ({
|
||||
id: mirror.getId(text.node as INode),
|
||||
value: text.value,
|
||||
})),
|
||||
attributes: attributes.map(attribute => ({
|
||||
id: mirror.getId(attribute.node as INode),
|
||||
attributes: attribute.attributes,
|
||||
})),
|
||||
texts: texts
|
||||
.map(text => ({
|
||||
id: mirror.getId(text.node as INode),
|
||||
value: text.value,
|
||||
}))
|
||||
// text mutation without ID means the target node has been removed
|
||||
.filter(text => text.id),
|
||||
attributes: attributes
|
||||
.map(attribute => ({
|
||||
id: mirror.getId(attribute.node as INode),
|
||||
attributes: attribute.attributes,
|
||||
}))
|
||||
// attribute mutation without ID means the target node has been removed
|
||||
.filter(attribute => attribute.id),
|
||||
removes,
|
||||
adds,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user