Skip to content

Commit

Permalink
Ran prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
okejminja committed Jun 29, 2023
1 parent c47332f commit 48fec9f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion packages/rrweb/src/record/mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
inDom,
getShadowHost,
getInlineCSSProperties,
} from '../utils'
} from '../utils';

type DoubleLinkedListNode = {
previous: DoubleLinkedListNode | null;
Expand Down
7 changes: 4 additions & 3 deletions packages/rrweb/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ export function getInlineCSSProperties(value: string | null): string[] {
if (!value) {
return [];
}
return value.split(';').map(declaration =>
declaration.split(':')[0].trim()
).filter(declaration => !!declaration);
return value
.split(';')
.map((declaration) => declaration.split(':')[0].trim())
.filter((declaration) => !!declaration);
}
22 changes: 13 additions & 9 deletions packages/rrweb/test/record.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
selectionData,
styleAttributeValue,
mutationData,
} from '@rrweb/types'
} from '@rrweb/types';
import {
assertSnapshot,
getServerURL,
Expand Down Expand Up @@ -298,11 +298,11 @@ describe('record', function (this: ISuite) {

setTimeout(() => {
div.setAttribute('style', 'background: var(--bg-orange)');
}, 5)
}, 5);

setTimeout(() => {
div.setAttribute('style', 'background-color: #000000');
}, 10)
}, 10);
});

await ctx.page.waitForTimeout(50);
Expand All @@ -311,19 +311,23 @@ describe('record', function (this: ISuite) {
(e) =>
e.type === EventType.IncrementalSnapshot &&
e.data.source === IncrementalSource.Mutation &&
e.data.attributes.length
e.data.attributes.length,
);

const expectedShorthandBackground =
((attributeMutationEvents[0].data as mutationData)?.attributes[0]?.attributes.style as styleAttributeValue)?.['background'];
const expectedLonghandBackground =
((attributeMutationEvents[1].data as mutationData)?.attributes[0]?.attributes.style as styleAttributeValue)?.['background'];
const expectedShorthandBackground = (
(attributeMutationEvents[0].data as mutationData)?.attributes[0]
?.attributes.style as styleAttributeValue
)?.['background'];
const expectedLonghandBackground = (
(attributeMutationEvents[1].data as mutationData)?.attributes[0]
?.attributes.style as styleAttributeValue
)?.['background'];

expect(attributeMutationEvents.length).toEqual(2);
expect(expectedShorthandBackground).toEqual('var(--bg-orange)');
expect(expectedLonghandBackground).toEqual(false);
assertSnapshot(ctx.events);
})
});

it('captures stylesheet rules', async () => {
await ctx.page.evaluate(() => {
Expand Down

0 comments on commit 48fec9f

Please sign in to comment.