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

Fix transfering multiple images when using srcset #99

Merged
merged 1 commit into from
Oct 8, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions blazy.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@
var onLoadHandler = function() {
// Is element an image
if (isImage) {
setSrc(ele, src); //src
handleSource(ele, _attrSrcset, options.srcset); //srcset
setSrc(ele, src); //src
//picture element
var parent = ele.parentNode;
if (parent && equal(parent, 'picture')) {
Expand All @@ -211,6 +211,12 @@
};
bindEvent(img, 'error', onErrorHandler);
bindEvent(img, 'load', onLoadHandler);

// preloading srcset
var dataSrc = ele.getAttribute(options.srcset);
if (dataSrc) {
img[_attrSrcset] = dataSrc;
}
setSrc(img, src); //preload
} else { // An item with src like iframe, unity, simpelvideo etc
setSrc(ele, src);
Expand Down Expand Up @@ -314,4 +320,4 @@
fn.apply(scope, arguments);
};
}
});
});