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