Skip to content

Commit ff98727

Browse files
committed
Add option to block animation on <title> tag which can generate massive recordings on some websites (think scrolling title tag)
1 parent 1f26708 commit ff98727

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

packages/rrweb/src/record/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ function record<T = eventWithTime>(
110110
// as they destroy some (hidden) info:
111111
headMetaAuthorship: _slimDOMOptions === 'all',
112112
headMetaDescKeywords: _slimDOMOptions === 'all',
113+
headTitleMutations: _slimDOMOptions === 'all', // block title tag 'animation' which can generate a lot of mutations that aren't usually displayed in replayers
113114
}
114115
: _slimDOMOptions
115116
? _slimDOMOptions

packages/rrweb/src/record/mutation.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export default class MutationBuffer {
429429
};
430430

431431
private processMutation = (m: mutationRecord) => {
432-
if (isIgnored(m.target)) {
432+
if (isIgnored(m.target, this.slimDOMOptions)) {
433433
return;
434434
}
435435
switch (m.type) {
@@ -529,7 +529,7 @@ export default class MutationBuffer {
529529
const parentId = isShadowRoot(m.target)
530530
? this.mirror.getId((m.target.host as unknown) as INode)
531531
: this.mirror.getId(m.target as INode);
532-
if (isBlocked(m.target, this.blockClass) || isIgnored(n)) {
532+
if (isBlocked(m.target, this.blockClass) || isIgnored(n, this.slimDOMOptions)) {
533533
return;
534534
}
535535
// removed node has not been serialized yet, just remove it from the Set
@@ -578,7 +578,7 @@ export default class MutationBuffer {
578578
return;
579579
}
580580
if (isINode(n)) {
581-
if (isIgnored(n)) {
581+
if (isIgnored(n, this.slimDOMOptions)) {
582582
return;
583583
}
584584
this.movedSet.add(n);

packages/rrweb/src/utils.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,13 @@ export function isBlocked(node: Node | null, blockClass: blockClass): boolean {
247247
return isBlocked(node.parentNode, blockClass);
248248
}
249249

250-
export function isIgnored(n: Node | INode): boolean {
250+
export function isIgnored(n: Node | INode, slimDOMOptions: SlimDOMOptions): boolean {
251+
if ((n as Node).tagName === 'TITLE' && slimDOMOptions.headTitleMutations) {
252+
// we do this check here but not in rrweb-snapshot
253+
// to block mutations/animations on the title.
254+
// the headTitleMutations options isn't intended to block recording of the initial value
255+
return true;
256+
}
251257
if ('__sn' in n) {
252258
return (n as INode).__sn.id === IGNORED_NODE;
253259
}

0 commit comments

Comments
 (0)