@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.
@@ -1288,9 +1288,10 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1288
1288
  if (!node || !node.childNodes) {
1289
1289
  return;
1290
1290
  }
1291
- const children = Array.from(node.childNodes);
1292
- children.forEach((child) => {
1293
- if (!child) return;
1291
+ let child = node.firstChild;
1292
+ while (child) {
1293
+ const next = child.nextSibling;
1294
+ const prev = child.previousSibling;
1294
1295
  if (child.nodeName.toLowerCase() === "a") {
1295
1296
  a(child, forApp, parentDomain, seoContext);
1296
1297
  }
@@ -1308,8 +1309,14 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1308
1309
  }
1309
1310
  if (child.parentNode) {
1310
1311
  traverse(child, forApp, depth + 1, state, parentDomain, seoContext);
1312
+ } else {
1313
+ const possibleReplacement = next ? next.previousSibling : node.lastChild;
1314
+ if (possibleReplacement && possibleReplacement !== prev && possibleReplacement.parentNode === node) {
1315
+ traverse(possibleReplacement, forApp, depth + 1, state, parentDomain, seoContext);
1316
+ }
1311
1317
  }
1312
- });
1318
+ child = next;
1319
+ }
1313
1320
  }
1314
1321
 
1315
1322
  // src/methods/clean-reply.method.ts