diff --git a/src/utils/dom/remove-empty.js b/src/utils/dom/remove-empty.js index 46346ba9..523c7769 100644 --- a/src/utils/dom/remove-empty.js +++ b/src/utils/dom/remove-empty.js @@ -1,7 +1,7 @@ export default function removeEmpty($article, $) { $article.find('p').each((index, p) => { const $p = $(p); - if ($p.text().trim() === '') $p.remove(); + if ($p.find('iframe, img').length === 0 && $p.text().trim() === '') $p.remove(); }); return $; diff --git a/src/utils/dom/remove-empty.test.js b/src/utils/dom/remove-empty.test.js index 7c7ab911..9cd4cfdd 100644 --- a/src/utils/dom/remove-empty.test.js +++ b/src/utils/dom/remove-empty.test.js @@ -27,5 +27,13 @@ describe('removeEmpty($)', () => { const result = removeEmpty($('*').first(), $); assertClean(result.html(), HTML.removeEmptyP.after); }); + + it('does not remove empty p tags containing an iframe', () => { + const html = '