Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Schalken committed Feb 1, 2021
1 parent 6970a72 commit 5acf5a5
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 5acf5a5

Please sign in to comment.