improve rrdom robustness (#1091)
This commit is contained in:
@@ -230,14 +230,24 @@ export class Replayer {
|
||||
else if (data.source === IncrementalSource.StyleDeclaration)
|
||||
this.applyStyleDeclaration(data, styleSheet);
|
||||
},
|
||||
afterAppend: (node: Node, id: number) => {
|
||||
for (const plugin of this.config.plugins || []) {
|
||||
if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });
|
||||
}
|
||||
},
|
||||
};
|
||||
this.iframe.contentDocument &&
|
||||
diff(
|
||||
this.iframe.contentDocument,
|
||||
this.virtualDom,
|
||||
replayerHandler,
|
||||
this.virtualDom.mirror,
|
||||
);
|
||||
if (this.iframe.contentDocument)
|
||||
try {
|
||||
diff(
|
||||
this.iframe.contentDocument,
|
||||
this.virtualDom,
|
||||
replayerHandler,
|
||||
this.virtualDom.mirror,
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn(e);
|
||||
}
|
||||
|
||||
this.virtualDom.destroyTree();
|
||||
this.usingVirtualDom = false;
|
||||
|
||||
@@ -858,6 +868,8 @@ export class Replayer {
|
||||
);
|
||||
}
|
||||
|
||||
// Skip the plugin onBuild callback in the virtual dom mode
|
||||
if (this.usingVirtualDom) return;
|
||||
for (const plugin of this.config.plugins || []) {
|
||||
if (plugin.onBuild)
|
||||
plugin.onBuild(builtNode, {
|
||||
@@ -1475,6 +1487,8 @@ export class Replayer {
|
||||
return;
|
||||
}
|
||||
const afterAppend = (node: Node | RRNode, id: number) => {
|
||||
// Skip the plugin onBuild callback for virtual dom
|
||||
if (this.usingVirtualDom) return;
|
||||
for (const plugin of this.config.plugins || []) {
|
||||
if (plugin.onBuild) plugin.onBuild(node, { id, replayer: this });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user