@ecency/render-helper 2.4.18 → 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
- Array.from(Array(node.childNodes.length).keys()).forEach((i) => {
1321
- const child = node.childNodes[i];
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
  }
@@ -1335,11 +1336,16 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1335
1336
  if (child.nodeName.toLowerCase() === "p") {
1336
1337
  p(child);
1337
1338
  }
1338
- const currentChild = node.childNodes[i];
1339
- if (currentChild) {
1340
- traverse(currentChild, forApp, depth + 1, state, parentDomain, seoContext);
1339
+ if (child.parentNode) {
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
+ }
1341
1346
  }
1342
- });
1347
+ child = next;
1348
+ }
1343
1349
  }
1344
1350
 
1345
1351
  // src/methods/clean-reply.method.ts