Skip to content

Commit

Permalink
childNodes instead of specific elements
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmparrish committed Sep 19, 2024
1 parent 24c6a56 commit 5d09c50
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/blocks/hero-marquee/hero-marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ function isElementEmpty(element) {
}
}
if (element.childNodes.length === 0) return true;
const nonEmptyElements = ['IMG', 'VIDEO', 'PICTURE', 'IFRAME', 'OBJECT', 'EMBED'];
for (const child of element.children) {
if (nonEmptyElements.includes(child.tagName) || !isElementEmpty(child)) {
if (child.hasChildNodes()) {
return false;
}
}
Expand Down Expand Up @@ -184,6 +183,7 @@ export default async function init(el) {
if (rows.length <= 1) return;
const [head, ...tail] = rows;
rows = tail;
console.log('isEmpty head', isElementEmpty(head), head, el);
if (isElementEmpty(head)) {
head.remove();

Check warning on line 188 in libs/blocks/hero-marquee/hero-marquee.js

View check run for this annotation

Codecov / codecov/patch

libs/blocks/hero-marquee/hero-marquee.js#L188

Added line #L188 was not covered by tests
} else {
Expand Down

0 comments on commit 5d09c50

Please sign in to comment.