Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
guntherjh authored and github-actions[bot] committed Oct 7, 2024
1 parent b408e08 commit 5d3fc0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function getTagName(n: elementNode): string {
export function adaptCssForReplay(cssText: string, cache: BuildCache): string {
const cachedStyle = cache?.stylesWithHoverClass.get(cssText);
if (cachedStyle) return cachedStyle;

let result = cssText;
try {
const ast: { css: string } = postcss([
Expand Down
9 changes: 7 additions & 2 deletions packages/rrweb-snapshot/test/rebuild.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,15 @@ ul li.specified c.\\:hover img {
});

it('handles exceptions from postcss when calling adaptCssForReplay', () => {
const consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const consoleWarnSpy = vi
.spyOn(console, 'warn')
.mockImplementation(() => {});
// trigger CssSyntaxError by passing invalid css
const cssText = 'a{';
adaptCssForReplay(cssText, cache);
expect(consoleWarnSpy).toHaveBeenLastCalledWith('Failed to adapt css for replay', expect.any(Error));
expect(consoleWarnSpy).toHaveBeenLastCalledWith(
'Failed to adapt css for replay',
expect.any(Error),
);
});
});

0 comments on commit 5d3fc0c

Please sign in to comment.