fix: Email for document update can include empty diff block

This commit is contained in:
Tom Moor
2023-07-07 08:23:42 -04:00
parent 814bacbead
commit 8cc2853102
3 changed files with 34 additions and 6 deletions

View File

@@ -195,6 +195,13 @@ export default class DocumentHelper {
const containsDiffElement = (node: Element | null) =>
node && node.innerHTML.includes("data-operation-index");
// The diffing lib isn't able to catch all changes currently, e.g. changing
// the type of a mark will result in an empty diff.
// see: https://github.com/tnwinc/htmldiff.js/issues/10
if (!containsDiffElement(doc.querySelector("#content"))) {
return;
}
// We use querySelectorAll to get a static NodeList as we'll be modifying
// it as we iterate, rather than getting content.childNodes.
const contents = doc.querySelectorAll("#content > *");