diff --git a/package.json b/package.json index 0d31af87..e676a7cf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@highlight-run/rrweb", - "version": "1.2.0", + "version": "1.2.1", "description": "record and replay the web", "scripts": { "test": "npm run bundle:browser && cross-env TS_NODE_CACHE=false TS_NODE_FILES=true mocha -r ts-node/register -r ignore-styles -r jsdom-global/register test/**.test.ts", diff --git a/src/replay/index.ts b/src/replay/index.ts index 4919e9d1..cb661bea 100644 --- a/src/replay/index.ts +++ b/src/replay/index.ts @@ -1964,9 +1964,15 @@ export class Replayer { ) { ((parent as unknown) as HTMLTextAreaElement).value = frag.textContent; } - parent.appendChild(frag); - // restore state of elements after they are mounted - this.restoreState(parent); + try { + parent.appendChild(frag); + // restore state of elements after they are mounted + this.restoreState(parent); + } catch (error) { + // this is likely due to a recording with + // invalid DOM nesting (a div under a p). don't crash rrweb in this case. + console.warn(error) + } } /**