Skip to content

Commit

Permalink
Merge pull request #29 from e-sites/develop
Browse files Browse the repository at this point in the history
extra check in image-lazyload module
  • Loading branch information
tomschalken authored Feb 1, 2021
2 parents 6970a72 + 5acf5a5 commit 95f0699
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/templates/_source/js/modules/ui/lazy-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ const loadComplete = ({ target }) => {
};

const loadImage = imgElement => {
const { src = null, srcset = null} = imgElement.dataset;
imgElement.addEventListener('load', loadComplete);
if ('srcset' in HTMLImageElement.prototype === false) {
imgElement.src = imgElement.dataset.src;
if (
'srcset' in HTMLImageElement.prototype === false ||
!srcset
) {
imgElement.src = src;
} else {
imgElement.srcset = imgElement.dataset.srcset;
imgElement.srcset = srcset;
}
};

Expand Down

0 comments on commit 95f0699

Please sign in to comment.