Closed tokkonopapa closed 9 years ago
Hello @tokkonopapa,
do you have any insight on how to fix this issue?
Thank you :-)
Hi @oncletom, For example, the following code suppresses unnecessary HTTP request.
getNaturalWidth = (function(){
if (Object.prototype.hasOwnProperty.call(document.createElement('img'), 'naturalWidth')) {
return function (image){ return image.naturalWidth;};
}
// IE8 and below lacks the naturalWidth property
return function (source){
var img = document.createElement('img');
img.src = source.src || "data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";
return img.width;
};
})();
When source.src
is undefined
, the object source
is HTMLDivElement
. I don't know why this happens.
It means the naturalWidth is somewhat performed while the element is not yet replaced by an image in the DOM.
I have seen such a similar error from time to time in the CI tests so I wonder if there is a ran-DOM race condition which would trigger your issue.
Thank you for your information.
In my experience, this can be found only in Firefox. So it seems not this project concern.
Regardless of any reason, waste of HTTP request is not good for us. So I left the above temporal code for who are intersted in this topic. And I will entrust to you that this issue should be closed or still opened.
Thanks again.
Let me know if you still encounter the issue when 0.3.1
is out.
0.3.1
is fine about this issue!
Thanks for your feedback @tokkonopapa :+1:
When
lazyload
is set totrue
, Firefox 29 fails to getnaturalWidth
and requestsundefined
URL from fallback function for IE8. Please check http://jsfiddle.net/tokkonoPapa/ms3c6/ or http://contentloaded.com/responsive/bbc-news/ .