@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.
@@ -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
- Array.from(Array(node.childNodes.length).keys()).forEach((i) => {
1289
- const child = node.childNodes[i];
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
  }
@@ -1303,11 +1304,16 @@ function traverse(node, forApp, depth = 0, state = { firstImageFound: false }, p
1303
1304
  if (child.nodeName.toLowerCase() === "p") {
1304
1305
  p(child);
1305
1306
  }
1306
- const currentChild = node.childNodes[i];
1307
- if (currentChild) {
1308
- traverse(currentChild, forApp, depth + 1, state, parentDomain, seoContext);
1307
+ if (child.parentNode) {
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
+ }
1309
1314
  }
1310
- });
1315
+ child = next;
1316
+ }
1311
1317
  }
1312
1318
 
1313
1319
  // src/methods/clean-reply.method.ts