Skip to content

Commit 8c759b5

Browse files
committed
Fix unloaded image issues, mostly in IE and Safari
Every now and then, the hiddenImage.onload function will fail, because the width and height of the hiddenImage are zero. The IE will throw an IndexSizeError in line 161, when it tries to get the image data. Safari fails silently. The reason for this is, that only the complete property is evaluated to consider the manual firing of the onload callback. But it can happen sometimes, that the complete property is true, but width and height are not calculated yet. So I added an extra test for the naturalWidth of the image. See also here: http://stackoverflow.com/questions/1977871/check-if-an-image-is-loaded-no-errors-in-javascript#answer-1977898
1 parent 82b42a6 commit 8c759b5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

resemble.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ URL: https://github.com/Huddle/Resemble.js
167167

168168
if (typeof fileData === 'string') {
169169
hiddenImage.src = fileData;
170-
if (hiddenImage.complete) {
170+
if (hiddenImage.complete && hiddenImage.naturalWidth > 0) {
171171
hiddenImage.onload();
172172
}
173173
} else if (typeof fileData.data !== 'undefined'

0 commit comments

Comments
 (0)