Skip to content
Merged
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
Next Next commit
fix: inline images onload
  • Loading branch information
wfk007 committed Mar 10, 2023
commit 43127104e38eb88e823bfc5f40bed20031f7069e
3 changes: 2 additions & 1 deletion packages/rrweb-snapshot/src/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ function serializeElementNode(
const oldValue = image.crossOrigin;
image.crossOrigin = 'anonymous';
const recordInlineImage = () => {
image.removeEventListener('load', recordInlineImage);
try {
canvasService!.width = image.naturalWidth;
canvasService!.height = image.naturalHeight;
Expand All @@ -755,7 +756,7 @@ function serializeElementNode(
};
// The image content may not have finished loading yet.
if (image.complete && image.naturalWidth !== 0) recordInlineImage();
else image.onload = recordInlineImage;
else image.addEventListener('load', recordInlineImage);
}
// media elements
if (tagName === 'audio' || tagName === 'video') {
Expand Down