From fc6c6c43d54b20ce582e3a6699e0352e0142ae12 Mon Sep 17 00:00:00 2001 From: Filip Slatinac Date: Sun, 1 Mar 2020 02:02:32 -0500 Subject: [PATCH] Checking node existence (#174) * added our package * reverted back to old rrweb snapshot * Array.from does not capture all elements added in the set, we have to manually iterate through the iterator * package lock * checking if nodes are in the parent before we try inserting them --- src/replay/index.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/replay/index.ts b/src/replay/index.ts index 3cdf8013..f2b15de5 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -409,7 +409,11 @@ export class Replayer { ) { parent.insertBefore(target, previous.nextSibling); } else if (next && next.parentNode) { - parent.insertBefore(target, next); + // making sure the parent contains the reference nodes + // before we insert target before next. + parent.contains(next) + ? parent.insertBefore(target, next) + : parent.insertBefore(target, null); } else { parent.appendChild(target); }