Skip to content

Commit

Permalink
Update lazyload.js
Browse files Browse the repository at this point in the history
  • Loading branch information
edwinbos authored Aug 28, 2019
1 parent b4e7e83 commit 79adc0e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lazyload.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,20 @@ var loadImage = function(elem) {

if (tagName == 'PICTURE') {
var sourceElements = elem.getElementsByTagName('source'),
imgElement = elem.getElementsByTagName('img')[0];
imgElement = elem.getElementsByTagName('img')[0],
dataSrc = imgElement.getAttribute('data-src');

for (var i = 0; i < sourceElements.length; i++) {
sourceElements[i].srcset = sourceElements[i].getAttribute('data-srcset');
}

imgElement.src = imgElement.getAttribute('data-src');
if (dataSrc) {
imgElement.src = dataSrc;
}
}

elem.classList.add('is-lazyloaded');
}

return lazyLoad;
});
});

0 comments on commit 79adc0e

Please sign in to comment.