fix: inline images onload (#1174)
* fix: inline images onload * add integration test case * Apply formatting changes * Create small-olives-arrive.md --------- Co-authored-by: Yun Feng <yun.feng0817@gmail.com>
This commit is contained in:
@@ -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;
|
||||
@@ -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') {
|
||||
|
||||
Reference in New Issue
Block a user