Skip to content

Commit

Permalink
Bugfix: after the crossOrigin change we always need to listen for the…
Browse files Browse the repository at this point in the history
… load, as calling `recordInlineImage` immediately will result in an empty data url
  • Loading branch information
eoghanmurray committed May 8, 2024
1 parent 71298d8 commit 236cd54
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ function serializeElementNode(
} catch (err) {
if (image.crossOrigin !== 'anonymous') {
image.crossOrigin = 'anonymous';
recordInlineImage();
image.addEventListener('load', recordInlineImage);
return;
} else {
console.warn(
Expand Down
3 changes: 2 additions & 1 deletion packages/rrweb-snapshot/test/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as rollup from 'rollup';
import * as typescript from 'rollup-plugin-typescript2';
import * as assert from 'assert';
import { waitForRAF } from './utils';
import { setTimeout } from 'node:timers/promises';

const _typescript = typescript as unknown as () => rollup.Plugin;

Expand Down Expand Up @@ -209,7 +210,7 @@ iframe.contentDocument.querySelector('center').clientHeight
inlineImages: true,
inlineStylesheet: false
})`);
await waitForRAF(page);
await setTimeout(20); // need a small wait, as after the crossOrigin="anonymous" change, the snapshot triggers a reload of the image (which mutates the snapshot when loaded)
const flat = (await page.evaluate(`
let flat = [];
function flatten(root) {
Expand Down

0 comments on commit 236cd54

Please sign in to comment.