@ecency/render-helper 2.4.19 → 2.4.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1317,9 +1317,10 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1317
1317
  if (!node || !node.childNodes) {
1318
1318
  return;
1319
1319
  }
1320
- const children = Array.from(node.childNodes);
1321
- children.forEach((child) => {
1322
- if (!child) return;
1320
+ let child = node.firstChild;
1321
+ while (child) {
1322
+ const next = child.nextSibling;
1323
+ const prev = child.previousSibling;
1323
1324
  if (child.nodeName.toLowerCase() === "a") {
1324
1325
  a(child, forApp, parentDomain, seoContext);
1325
1326
  }
@@ -1337,8 +1338,14 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1337
1338
  }
1338
1339
  if (child.parentNode) {
1339
1340
  traverse(child, forApp, depth + 1, state, parentDomain, seoContext);
1341
+ } else {
1342
+ const possibleReplacement = next ? next.previousSibling : node.lastChild;
1343
+ if (possibleReplacement && possibleReplacement !== prev && possibleReplacement.parentNode === node) {
1344
+ traverse(possibleReplacement, forApp, depth + 1, state, parentDomain, seoContext);
1345
+ }
1340
1346
  }
1341
- });
1347
+ child = next;
1348
+ }
1342
1349
  }
1343
1350
 
1344
1351
  // src/methods/clean-reply.method.ts