improve: add try catch to snapshot.ts 's masking text function (#1148)
* improve: add try catch to snapshot.ts to make it robust * add change log
This commit is contained in:
5
.changeset/pretty-schools-remember.md
Normal file
5
.changeset/pretty-schools-remember.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'rrweb-snapshot': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve: Add try catch to snapshot.ts 's masking text function. Fixes [#1118](https://github.com/rrweb-io/rrweb/issues/1118).
|
||||||
@@ -268,6 +268,7 @@ export function _isBlockedElement(
|
|||||||
blockClass: string | RegExp,
|
blockClass: string | RegExp,
|
||||||
blockSelector: string | null,
|
blockSelector: string | null,
|
||||||
): boolean {
|
): boolean {
|
||||||
|
try {
|
||||||
if (typeof blockClass === 'string') {
|
if (typeof blockClass === 'string') {
|
||||||
if (element.classList.contains(blockClass)) {
|
if (element.classList.contains(blockClass)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -283,6 +284,9 @@ export function _isBlockedElement(
|
|||||||
if (blockSelector) {
|
if (blockSelector) {
|
||||||
return element.matches(blockSelector);
|
return element.matches(blockSelector);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -313,6 +317,7 @@ export function needMaskingText(
|
|||||||
maskTextClass: string | RegExp,
|
maskTextClass: string | RegExp,
|
||||||
maskTextSelector: string | null,
|
maskTextSelector: string | null,
|
||||||
): boolean {
|
): boolean {
|
||||||
|
try {
|
||||||
const el: HTMLElement | null =
|
const el: HTMLElement | null =
|
||||||
node.nodeType === node.ELEMENT_NODE
|
node.nodeType === node.ELEMENT_NODE
|
||||||
? (node as HTMLElement)
|
? (node as HTMLElement)
|
||||||
@@ -330,6 +335,9 @@ export function needMaskingText(
|
|||||||
if (el.matches(maskTextSelector)) return true;
|
if (el.matches(maskTextSelector)) return true;
|
||||||
if (el.closest(maskTextSelector)) return true;
|
if (el.closest(maskTextSelector)) return true;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
//
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user