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 srcset support #93

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
14 changes: 7 additions & 7 deletions dist/jquery.waitforimages.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! waitForImages jQuery Plugin - v2.4.0 - 2018-02-13
* https://github.com/alexanderdickson/waitForImages
* Copyright (c) 2018 Alex Dickson; Licensed MIT */
/*! waitForImages jQuery Plugin - v2.5.0 - 2018-03-08
* https://github.com/alexanderdickson/waitForImages
* Copyright (c) 2018 Alex Dickson; Licensed MIT */
;(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
Expand All @@ -18,7 +18,7 @@

// Is srcset supported by this browser?
var hasSrcset = (function(img) {
return img.srcset && img.sizes;
return img.srcset !== undefined && img.sizes !== undefined;
})(new Image());

// CSS properties which contain references to images.
Expand Down Expand Up @@ -216,9 +216,9 @@

});

if (hasSrcset && img.srcset) {
image.srcset = img.srcset;
image.sizes = img.sizes;
if (hasSrcset && img.element.srcset) {
image.srcset = img.element.srcset;
image.sizes = img.element.sizes;
}
image.src = img.src;
});
Expand Down
4 changes: 2 additions & 2 deletions dist/jquery.waitforimages.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"email": "[email protected]",
"url": "http://alexanderdickson.com"
},
"version": "2.4.0",
"version": "2.5.0",
"homepage": "https://github.com/alexanderdickson/waitForImages",
"bugs": {
"url": "https://github.com/alexanderdickson/waitForImages/issues"
Expand Down
8 changes: 4 additions & 4 deletions src/jquery.waitforimages.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

// Is srcset supported by this browser?
var hasSrcset = (function(img) {
return img.srcset && img.sizes;
return img.srcset !== undefined && img.sizes !== undefined;
})(new Image());

// CSS properties which contain references to images.
Expand Down Expand Up @@ -213,9 +213,9 @@

});

if (hasSrcset && img.srcset) {
image.srcset = img.srcset;
image.sizes = img.sizes;
if (hasSrcset && img.element.srcset) {
image.srcset = img.element.srcset;
image.sizes = img.element.sizes;
}
image.src = img.src;
});
Expand Down