diff --git a/packages/rrweb/src/replay/index.ts b/packages/rrweb/src/replay/index.ts index 66e727b134..3854c84bde 100644 --- a/packages/rrweb/src/replay/index.ts +++ b/packages/rrweb/src/replay/index.ts @@ -1401,7 +1401,11 @@ export class Replayer { /** * Why !isIframeINode(parent)? If parent element is an iframe, iframe document can't be appended to virtual parent. * Why !hasIframeChild? If we move iframe elements from dom to fragment document, we will lose the contentDocument of iframe. So we need to disable the virtual dom optimization if a parent node contains iframe elements. + * Why parent.tagName !== 'HEAD'? moving stylesheets out of the element removes the styles from the document (and they don't get replaced at `parent = virtualParent` */ + if (((parent as unknown) as HTMLElement).tagName === 'HEAD') { + useVirtualParent = false; // cancel for this and any other additions in same mutation + } if ( useVirtualParent && parentInDocument &&