Skip to content

Commit f59f381

Browse files
authored
Merge pull request #59 from OneNoteDev/bug/blank-img-race-condition
Fix blank image recognition race condition
2 parents 00af69f + 5e36472 commit f59f381

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/scripts/domParsers/domUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ export module DomUtils {
360360
// Just passing in the image node won't work as it won't render properly
361361
// and the algorithm will think every pixel is (0,0,0,0)
362362
let theImg = new Image();
363-
theImg.src = img.src;
364363

365364
// In Firefox, a SecurityError is thrown if the image is not CORS-enabled
366365
theImg.crossOrigin = "anonymous";
@@ -372,6 +371,9 @@ export module DomUtils {
372371
theImg.onerror = () => {
373372
resolve(undefined);
374373
};
374+
375+
// The request is kicked off as soon as the src is set, so it needs to happen last
376+
theImg.src = img.src;
375377
});
376378
});
377379
}

0 commit comments

Comments
 (0)