From c3a8d22589ef398a66d518df8b05f623dfb4f06c Mon Sep 17 00:00:00 2001 From: Michael Dellanoce Date: Fri, 8 Dec 2023 09:47:09 -0500 Subject: [PATCH] allow passing null to maskTextClass/blockClass --- .changeset/quick-cows-chew.md | 5 +++++ packages/rrweb-snapshot/src/snapshot.ts | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 .changeset/quick-cows-chew.md diff --git a/.changeset/quick-cows-chew.md b/.changeset/quick-cows-chew.md new file mode 100644 index 0000000000..f06fba27b0 --- /dev/null +++ b/.changeset/quick-cows-chew.md @@ -0,0 +1,5 @@ +--- +'rrweb-snapshot': patch +--- + +allow passing null to maskTextClass/blockClass diff --git a/packages/rrweb-snapshot/src/snapshot.ts b/packages/rrweb-snapshot/src/snapshot.ts index 0201b9c647..7ee57be131 100644 --- a/packages/rrweb-snapshot/src/snapshot.ts +++ b/packages/rrweb-snapshot/src/snapshot.ts @@ -268,7 +268,7 @@ export function _isBlockedElement( if (element.classList.contains(blockClass)) { return true; } - } else { + } else if (blockClass) { for (let eIndex = element.classList.length; eIndex--; ) { const className = element.classList[eIndex]; if (blockClass.test(className)) { @@ -292,6 +292,7 @@ export function classMatchesRegex( checkAncestors: boolean, ): boolean { if (!node) return false; + if (!regex) return false; if (node.nodeType !== node.ELEMENT_NODE) { if (!checkAncestors) return false; return classMatchesRegex(node.parentNode, regex, checkAncestors);