Skip to content

Commit

Permalink
remove default for unmaskTextClass rrweb-io#1096
Browse files Browse the repository at this point in the history
  • Loading branch information
mdellanoce committed Mar 14, 2023
1 parent 68323b1 commit 58dffc1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ The parameter of `rrweb.record` accepts the following options.
| ignoreCSSAttributes | null | array of CSS attributes that should be ignored |
| maskAllText | false | mask all text content as \* |
| maskTextClass | 'rr-mask' | Use a string or RegExp to configure which elements should be masked, refer to the [privacy](#privacy) chapter |
| unmaskTextClass | 'rr-unmask' | Use a string or RegExp to configure which elements should be unmasked, refer to the [privacy](#privacy) chapter |
| unmaskTextClass | null | Use a string or RegExp to configure which elements should be unmasked, refer to the [privacy](#privacy) chapter |
| maskTextSelector | null | Use a string to configure which selector should be masked, refer to the [privacy](#privacy) chapter |
| unmaskTextSelector | null | Use a string to configure which selector should be unmasked, refer to the [privacy](#privacy) chapter |
| maskAllInputs | false | mask all input content as \* |
Expand Down Expand Up @@ -174,7 +174,7 @@ You may find some contents on the webpage which are not willing to be recorded,
- An element with the class name `.rr-block` will not be recorded. Instead, it will replay as a placeholder with the same dimension.
- An element with the class name `.rr-ignore` will not record its input events.
- All text of elements with the class name `.rr-mask` and their children will be masked.
- All text of elements with the class name `.rr-unmask` and their children will be unmasked, unless any child is marked with `.rr-mask`.
- All text of elements with the optional unmasking class name `unmaskTextClass` and their children will be unmasked, unless any child is marked with `.rr-mask`.
- `input[type="password"]` will be masked by default.
- Mask options to mask the content in input elements.

Expand Down
26 changes: 14 additions & 12 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,16 +343,18 @@ function distanceToSelectorMatch(el: HTMLElement, selector: string): number {

function distanceToMatch(
el: HTMLElement,
className: string | RegExp,
className: string | RegExp | null,
selector: string | null,
): number {
let classDistance = -1;
let selectorDistance = -1;

if (typeof className === 'string') {
classDistance = distanceToSelectorMatch(el, `.${className}`);
} else {
classDistance = distanceToClassRegexMatch(el, className, true);
if (className) {
if (typeof className === 'string') {
classDistance = distanceToSelectorMatch(el, `.${className}`);
} else {
classDistance = distanceToClassRegexMatch(el, className, true);
}
}

if (selector) {
Expand All @@ -372,7 +374,7 @@ export function needMaskingText(
node: Node,
maskTextClass: string | RegExp,
maskTextSelector: string | null,
unmaskTextClass: string | RegExp,
unmaskTextClass: string | RegExp | null,
unmaskTextSelector: string | null,
maskAllText: boolean,
): boolean {
Expand Down Expand Up @@ -491,7 +493,7 @@ function serializeNode(
blockSelector: string | null;
maskAllText: boolean;
maskTextClass: string | RegExp;
unmaskTextClass: string | RegExp;
unmaskTextClass: string | RegExp | null;
maskTextSelector: string | null;
unmaskTextSelector: string | null;
inlineStylesheet: boolean;
Expand Down Expand Up @@ -610,7 +612,7 @@ function serializeTextNode(
options: {
maskAllText: boolean;
maskTextClass: string | RegExp;
unmaskTextClass: string | RegExp;
unmaskTextClass: string | RegExp | null;
maskTextSelector: string | null;
unmaskTextSelector: string | null;
maskTextFn: MaskTextFn | undefined;
Expand Down Expand Up @@ -702,7 +704,7 @@ function serializeElementNode(
rootId: number | undefined;
maskAllText: boolean;
maskTextClass: string | RegExp;
unmaskTextClass: string | RegExp;
unmaskTextClass: string | RegExp | null;
maskTextSelector: string | null;
unmaskTextSelector: string | null;
},
Expand Down Expand Up @@ -1034,7 +1036,7 @@ export function serializeNodeWithId(
blockClass: string | RegExp;
blockSelector: string | null;
maskTextClass: string | RegExp;
unmaskTextClass: string | RegExp;
unmaskTextClass: string | RegExp | null;
maskTextSelector: string | null;
unmaskTextSelector: string | null;
skipChild: boolean;
Expand Down Expand Up @@ -1330,7 +1332,7 @@ function snapshot(
blockSelector?: string | null;
maskAllText?: boolean;
maskTextClass?: string | RegExp;
unmaskTextClass?: string | RegExp;
unmaskTextClass?: string | RegExp | null;
maskTextSelector?: string | null;
unmaskTextSelector?: string | null;
inlineStylesheet?: boolean;
Expand Down Expand Up @@ -1362,7 +1364,7 @@ function snapshot(
blockSelector = null,
maskAllText = false,
maskTextClass = 'rr-mask',
unmaskTextClass = 'rr-unmask',
unmaskTextClass = null,
maskTextSelector = null,
unmaskTextSelector = null,
inlineStylesheet = true,
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function record<T = eventWithTime>(
ignoreClass = 'rr-ignore',
maskAllText = false,
maskTextClass = 'rr-mask',
unmaskTextClass = 'rr-unmask',
unmaskTextClass = null,
maskTextSelector = null,
unmaskTextSelector = null,
inlineStylesheet = true,
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export type canvasEventWithTime = eventWithTime & {
export type blockClass = string | RegExp;

export type maskTextClass = string | RegExp;
export type unmaskTextClass = string | RegExp;
export type unmaskTextClass = string | RegExp | null;

export type SamplingStrategy = Partial<{
/**
Expand Down

0 comments on commit 58dffc1

Please sign in to comment.