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);