Skip to content

Commit

Permalink
I missed the checkAncestors:true argument on needMaskingText with the…
Browse files Browse the repository at this point in the history
… text mutation - modify the test to show where this would have failed
  • Loading branch information
eoghanmurray committed Nov 8, 2023
1 parent b5843a7 commit aa046c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ export default class MutationBuffer {
m.target,
this.maskTextClass,
this.maskTextSelector,
true, // checkAncestors
) && value
? this.maskTextFn
? this.maskTextFn(value, closestElementOfNode(m.target))
Expand Down
14 changes: 9 additions & 5 deletions packages/rrweb/test/__snapshots__/integration.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,12 @@ exports[`record integration tests can mask character data mutations with regexp
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 10,
\\"attributes\\": {
\\"class\\": \\"custom-mask\\"
}
},
{
\\"id\\": 7,
\\"attributes\\": {
Expand All @@ -984,9 +990,7 @@ exports[`record integration tests can mask character data mutations with regexp
\\"node\\": {
\\"type\\": 2,
\\"tagName\\": \\"li\\",
\\"attributes\\": {
\\"class\\": \\"custom-mask\\"
},
\\"attributes\\": {},
\\"childNodes\\": [],
\\"id\\": 20
}
Expand Down Expand Up @@ -1018,8 +1022,8 @@ exports[`record integration tests can mask character data mutations with regexp
\\"source\\": 0,
\\"texts\\": [
{
\\"id\\": 22,
\\"value\\": \\"****** *******\\"
\\"id\\": 21,
\\"value\\": \\"********** ****** ** ****** *** **** ****\\"
}
],
\\"attributes\\": [],
Expand Down
6 changes: 3 additions & 3 deletions packages/rrweb/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ describe('record integration tests', function (this: ISuite) {
const li = document.createElement('li');
const ul = document.querySelector('ul') as HTMLUListElement;
const p = document.querySelector('p') as HTMLParagraphElement;
[li, p].forEach((element) => {
[ul, p].forEach((element) => {
element.className = 'custom-mask';
});
ul.appendChild(li);
Expand All @@ -1242,8 +1242,8 @@ describe('record integration tests', function (this: ISuite) {

await page.evaluate(() => {
// generate a characterData mutation; innerText doesn't do that
const p = document.querySelector('p') as HTMLParagraphElement;
(p.childNodes[0] as Text).insertData(0, 'doubly ');
const li = document.querySelector('li:not(:empty)') as HTMLLIElement;
(li.childNodes[0] as Text).insertData(0, 'descendent should be masked ');
});

const snapshots = (await page.evaluate(
Expand Down

0 comments on commit aa046c4

Please sign in to comment.