Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Are images guaranteed to be loaded? #2

Open
ixchow opened this issue Jan 27, 2015 · 2 comments
Open

Are images guaranteed to be loaded? #2

ixchow opened this issue Jan 27, 2015 · 2 comments

Comments

@ixchow
Copy link
Owner

ixchow commented Jan 27, 2015

Currently, sald produces code like this for images:

  'img/hero1.png' : function(module) {
    var img = new Image();
    img.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAArElEQVQ4jWNgGHGAEcZInv3/PyUGzU1lZIQbmDz7//8flx9R5DIOXTmGuamMjIzUMAzZUCaqmIQERg2kHFA/2cAEqJqwcQGYyzl05RgYGBgYYGyYZmxg8EcKVgP1fIob8IVp8uz///V8ihuwyTFjM8zUv6f+x+VHDH9efWRgYGBgYBHnZ2BgYGD48+ojHMvbhTr8/f+F8eWt4weQ9WMNXFy2o4NLW3qJUkcRAACG/UtF0Jd+kAAAAABJRU5ErkJggg==";
    module.exports = img;},

When setting an Image's src to an http: URI, the image may or may not be loaded until its onload event fires. We need to test if this is also ever the case with data: URIs, and -- if so -- change the loading code.

@ixchow
Copy link
Owner Author

ixchow commented Jan 27, 2015

Note, on Chrome on OSX, it appears that an Image with its src set to a data URI immediately has a valid "width" property, at least.

@jslone
Copy link
Contributor

jslone commented Jan 27, 2015

I found this, though it's old enough the results are likely not still valid. The simplest solution seems like it would be to make the function spin in a loop until onload gets called, but that's awfully hacky.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants