Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
tested ignoreCSSAttributes
  • Loading branch information
Filip authored and dbseel committed Jun 14, 2022
commit a55b7f88161cda732954c8076d94270667aa0efa
3 changes: 0 additions & 3 deletions packages/rrweb/src/record/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ function record<T = eventWithTime>(
keepIframeSrcFn = () => false,
ignoreCSSAttributes = new Set([]),
} = options;
options.ignoreCSSAttributes?.forEach((s) => {
console.log(`element: ${s}`);
});

// runtime checks for user options
if (!emit) {
Expand Down
2 changes: 0 additions & 2 deletions packages/rrweb/src/record/observer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,6 @@ function initStyleDeclarationObserver(
) {
// ignore this mutation if we do not care about this css attribute
if (ignoreCSSAttributes.has(property)) {
console.log('here?');
return setProperty.apply(this, arguments);
}
const id = mirror.getId(this.parentRule?.parentStyleSheet?.ownerNode);
Expand All @@ -635,7 +634,6 @@ function initStyleDeclarationObserver(
) {
// ignore this mutation if we do not care about this css attribute
if (ignoreCSSAttributes.has(property)) {
console.log('here??');
return setProperty.apply(this, arguments);
}
const id = mirror.getId(this.parentRule?.parentStyleSheet?.ownerNode);
Expand Down
2 changes: 1 addition & 1 deletion packages/rrweb/test/__snapshots__/record.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ exports[`record captures style property changes 1`] = `
\\"source\\": 13,
\\"id\\": 9,
\\"set\\": {
\\"property\\": \\"color\\",
\\"property\\": \\"border-color\\",
\\"value\\": \\"green\\"
},
\\"index\\": [
Expand Down
37 changes: 9 additions & 28 deletions packages/rrweb/test/record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ describe('record', function (this: ISuite) {

record({
emit: ((window as unknown) as IWindow).emit,
ignoreCSSAttributes: new Set(['color']),
});

const styleElement = document.createElement('style');
Expand All @@ -332,10 +333,18 @@ describe('record', function (this: ISuite) {
const styleSheet = <CSSStyleSheet>styleElement.sheet;
styleSheet.insertRule('body { background: #000; }');
setTimeout(() => {
// should be ignored
(styleSheet.cssRules[0] as CSSStyleRule).style.setProperty(
'color',
'green',
);

// should be captured because we did not block it
(styleSheet.cssRules[0] as CSSStyleRule).style.setProperty(
'border-color',
'green',
);

(styleSheet.cssRules[0] as CSSStyleRule).style.removeProperty(
'background',
);
Expand All @@ -345,34 +354,6 @@ describe('record', function (this: ISuite) {
assertSnapshot(ctx.events);
});

// it('does not capture style property changes when the css element is ignored', async () => {
// await ctx.page.evaluate(() => {
// const { record } = ((window as unknown) as IWindow).rrweb;

// record({
// emit: ((window as unknown) as IWindow).emit,
// ignoreCSSAttributes: new Set(['color']),
// });

// const styleElement = document.createElement('style');
// document.head.appendChild(styleElement);

// const styleSheet = <CSSStyleSheet>styleElement.sheet;
// styleSheet.insertRule('body { background: #000; }');
// setTimeout(() => {
// (styleSheet.cssRules[0] as CSSStyleRule).style.setProperty(
// 'color',
// 'green',
// );
// (styleSheet.cssRules[0] as CSSStyleRule).style.removeProperty(
// 'background',
// );
// }, 0);
// });
// await ctx.page.waitForTimeout(50);
// assertSnapshot(ctx.events);
// });

it('captures inserted style text nodes correctly', async () => {
await ctx.page.evaluate(() => {
const { record } = ((window as unknown) as IWindow).rrweb;
Expand Down