Files
rrweb/src/record/shadow-dom-manager.ts
Yanzhen Yu 0e688bba0c impl shadow DOM manager
part of #38
1. observe DOM mutations in shadow DOM
2. rebuild DOM mutations in shadow DOM
2026-04-01 12:00:00 +08:00

44 lines
1.2 KiB
TypeScript

import { mutationCallBack, blockClass } from '../types';
import { MaskInputOptions, SlimDOMOptions } from 'rrweb-snapshot';
import { IframeManager } from './iframe-manager';
import { initMutationObserver } from './observer';
type BypassOptions = {
blockClass: blockClass;
blockSelector: string | null;
inlineStylesheet: boolean;
maskInputOptions: MaskInputOptions;
recordCanvas: boolean;
slimDOMOptions: SlimDOMOptions;
iframeManager: IframeManager;
};
export class ShadowDomManager {
private mutationCb: mutationCallBack;
private bypassOptions: BypassOptions;
constructor(options: {
mutationCb: mutationCallBack;
bypassOptions: BypassOptions;
}) {
this.mutationCb = options.mutationCb;
this.bypassOptions = options.bypassOptions;
}
public addShadowRoot(shadowRoot: ShadowRoot, doc: Document) {
initMutationObserver(
this.mutationCb,
doc,
this.bypassOptions.blockClass,
this.bypassOptions.blockSelector,
this.bypassOptions.inlineStylesheet,
this.bypassOptions.maskInputOptions,
this.bypassOptions.recordCanvas,
this.bypassOptions.slimDOMOptions,
this.bypassOptions.iframeManager,
this,
shadowRoot,
);
}
}