rewrite mutation observer handler with lazy child list calculation

This commit is contained in:
Yanzhen Yu
2018-10-22 23:08:05 +08:00
parent a88a79d821
commit d588f738b8
6 changed files with 112 additions and 36 deletions

View File

@@ -4,6 +4,7 @@ import {
listenerHandler,
hookResetter,
} from './types';
import { INode } from 'rrweb-snapshot';
export function on(
type: string,
@@ -26,6 +27,11 @@ export const mirror: Mirror = {
removeNodeFromMap(n) {
const id = n.__sn && n.__sn.id;
delete mirror.map[id];
if (n.childNodes) {
n.childNodes.forEach(child =>
mirror.removeNodeFromMap((child as Node) as INode),
);
}
},
};