From 17d066c9d34f83639081e3805477ac915b77177b Mon Sep 17 00:00:00 2001 From: John Pham Date: Mon, 13 Sep 2021 11:40:18 -0700 Subject: [PATCH 1/3] Apply #696 --- src/record/mutation.ts | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/record/mutation.ts b/src/record/mutation.ts index 2e62b2ee..b3e9a3d7 100644 --- a/src/record/mutation.ts +++ b/src/record/mutation.ts @@ -264,9 +264,6 @@ export default class MutationBuffer { ns = ns && ns.nextSibling; nextId = ns && this.mirror.getId((ns as unknown) as INode); } - if (nextId === -1 && isBlocked(n.nextSibling, this.blockClass)) { - nextId = null; - } return nextId; }; const pushAdd = (n: Node) => { @@ -506,11 +503,7 @@ export default class MutationBuffer { const parentId = isShadowRoot(m.target) ? this.mirror.getId((m.target.host as unknown) as INode) : this.mirror.getId(m.target as INode); - if ( - isBlocked(n, this.blockClass) || - isBlocked(m.target, this.blockClass) || - isIgnored(n) - ) { + if (isBlocked(m.target, this.blockClass) || isIgnored(n)) { return; } // removed node has not been serialized yet, just remove it from the Set @@ -554,9 +547,7 @@ export default class MutationBuffer { }; private genAdds = (n: Node | INode, target?: Node | INode) => { - if (isBlocked(n, this.blockClass)) { - return; - } + // parent was blocked, so we can ignore this node if (target && isBlocked(target, this.blockClass)) { return; } @@ -576,7 +567,10 @@ export default class MutationBuffer { this.addedSet.add(n); this.droppedSet.delete(n); } - n.childNodes.forEach((childN) => this.genAdds(childN)); + // if this node is blocked `serializeNode` will turn it into a placeholder element + // but we have to remove it's children otherwise they will be added as placeholders too + if (!isBlocked(n, this.blockClass)) + n.childNodes.forEach((childN) => this.genAdds(childN)); }; } From 37b62c664ed78e16bbc23bac73fd456fb28d8ce0 Mon Sep 17 00:00:00 2001 From: John Pham Date: Mon, 13 Sep 2021 11:44:14 -0700 Subject: [PATCH 2/3] Apply 693 --- src/record/observer.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/record/observer.ts b/src/record/observer.ts index 5a7eb59d..4c977dd5 100644 --- a/src/record/observer.ts +++ b/src/record/observer.ts @@ -60,6 +60,8 @@ type WindowWithAngularZone = Window & { export const mutationBuffers: MutationBuffer[] = []; +const isCSSGroupingRuleSupported = typeof CSSGroupingRule !== 'undefined'; + function getEventTarget(event: Event): EventTarget | null { try { if ('composedPath' in event) { @@ -500,7 +502,10 @@ function initInputObserver( function getNestedCSSRulePositions(rule: CSSRule): number[] { const positions: number[] = []; function recurse(childRule: CSSRule, pos: number[]) { - if (childRule.parentRule instanceof CSSGroupingRule) { + if ( + isCSSGroupingRuleSupported && + childRule.parentRule instanceof CSSGroupingRule + ) { const rules = Array.from( (childRule.parentRule as CSSGroupingRule).cssRules, ); @@ -544,6 +549,13 @@ function initStyleSheetObserver( return deleteRule.apply(this, arguments); }; + if (!isCSSGroupingRuleSupported) { + return () => { + CSSStyleSheet.prototype.insertRule = insertRule; + CSSStyleSheet.prototype.deleteRule = deleteRule; + }; + } + const groupingInsertRule = CSSGroupingRule.prototype.insertRule; CSSGroupingRule.prototype.insertRule = function ( rule: string, From 67e79145a543e03b153585aa03aab02f1ddcec71 Mon Sep 17 00:00:00 2001 From: John Pham Date: Mon, 13 Sep 2021 11:44:26 -0700 Subject: [PATCH 3/3] Bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 383e80b6..b65c0d39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@highlight-run/rrweb", - "version": "0.12.9", + "version": "0.12.10", "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",