Skip to content
This repository has been archived by the owner on Jul 10, 2023. It is now read-only.

Commit

Permalink
Revert "Fix for issue with inlineImages causing images to reload and …
Browse files Browse the repository at this point in the history
…never be inlined. See rrweb-io#1218"

This reverts commit 4cf2b1b.
  • Loading branch information
econte-sprig committed May 9, 2023
1 parent 4cf2b1b commit 936a422
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,8 +744,10 @@ function serializeElementNode(
canvasCtx = canvasService.getContext('2d');
}
const image = n as HTMLImageElement;
// The image content may not have finished loading yet.
if (image.complete && image.naturalWidth !== 0) {
const oldValue = image.crossOrigin;
image.crossOrigin = 'anonymous';
const recordInlineImage = () => {
image.removeEventListener('load', recordInlineImage);
try {
canvasService!.width = image.naturalWidth;
canvasService!.height = image.naturalHeight;
Expand All @@ -759,7 +761,13 @@ function serializeElementNode(
`Cannot inline img src=${image.currentSrc}! Error: ${err as string}`,
);
}
}
oldValue
? (attributes.crossOrigin = oldValue)
: image.removeAttribute('crossorigin');
};
// The image content may not have finished loading yet.
if (image.complete && image.naturalWidth !== 0) recordInlineImage();
else image.addEventListener('load', recordInlineImage);
}
// media elements
if (tagName === 'audio' || tagName === 'video') {
Expand Down

0 comments on commit 936a422

Please sign in to comment.