Don’t remove top level <br> tags that separate text nodes (Apple calendar alerts)

This commit is contained in:
Ben Gotow 2020-05-24 18:59:15 -05:00
parent 4c6ab52e5a
commit df26391c57

View file

@ -105,12 +105,13 @@ class QuotedHTMLTransformer {
return; return;
} }
// Find back-to-back <br><br> at the top level and de-duplicate them // Find back-to-back <br><br> at the top level and de-duplicate them. Note that
const { children } = doc.body; // some emails contain TEXT<br>TEXT<br>TEXT, so the only ELEMENT children may be the <brs>
const nodes = doc.body.childNodes;
const extraTailBrTags = []; const extraTailBrTags = [];
for (let i = children.length - 1; i >= 0; i--) { for (let i = nodes.length - 1; i >= 0; i--) {
const curr = children[i]; const curr = nodes[i];
const next = children[i - 1]; const next = nodes[i - 1];
if (curr && curr.nodeName === 'BR' && next && next.nodeName === 'BR') { if (curr && curr.nodeName === 'BR' && next && next.nodeName === 'BR') {
extraTailBrTags.push(curr); extraTailBrTags.push(curr);
} else { } else {