Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
1.10.0 release
  • Loading branch information
ApoorvSaxena committed Jun 5, 2019
1 parent 3ae5f9b commit 62ceb52
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 9 deletions.
16 changes: 14 additions & 2 deletions dist/lozad.es.js
@@ -1,4 +1,4 @@
/*! lozad.js - v1.9.0 - 2019-06-06
/*! lozad.js - v1.10.0 - 2019-06-06
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

Expand All @@ -19,11 +19,14 @@ const defaultConfig = {
if (isIE && element.getAttribute('data-iesrc')) {
img.src = element.getAttribute('data-iesrc');
}

if (element.getAttribute('data-alt')) {
img.alt = element.getAttribute('data-alt');
}
element.appendChild(img);

element.append(img);
}

if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
if (element.children) {
const childs = element.children;
Expand All @@ -34,18 +37,23 @@ const defaultConfig = {
childs[i].src = childSrc;
}
}

element.load();
}
}

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

if (element.getAttribute('data-srcset')) {
element.setAttribute('srcset', element.getAttribute('data-srcset'));
}

if (element.getAttribute('data-background-image')) {
element.style.backgroundImage = `url('${element.getAttribute('data-background-image')}')`;
}

if (element.getAttribute('data-toggle-class')) {
element.classList.toggle(element.getAttribute('data-toggle-class'));
}
Expand Down Expand Up @@ -77,9 +85,11 @@ const getElements = (selector, root = document) => {
if (selector instanceof Element) {
return [selector]
}

if (selector instanceof NodeList) {
return selector
}

return root.querySelectorAll(selector)
};

Expand All @@ -103,10 +113,12 @@ function lozad (selector = '.lozad', options = {}) {
if (isLoaded(elements[i])) {
continue
}

if (observer) {
observer.observe(elements[i]);
continue
}

load(elements[i]);
markAsLoaded(elements[i]);
loaded(elements[i]);
Expand Down
16 changes: 14 additions & 2 deletions dist/lozad.js
@@ -1,4 +1,4 @@
/*! lozad.js - v1.9.0 - 2019-06-06
/*! lozad.js - v1.10.0 - 2019-06-06
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

Expand Down Expand Up @@ -27,11 +27,14 @@
if (isIE && element.getAttribute('data-iesrc')) {
img.src = element.getAttribute('data-iesrc');
}

if (element.getAttribute('data-alt')) {
img.alt = element.getAttribute('data-alt');
}
element.appendChild(img);

element.append(img);
}

if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
if (element.children) {
var childs = element.children;
Expand All @@ -42,18 +45,23 @@
childs[i].src = childSrc;
}
}

element.load();
}
}

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

if (element.getAttribute('data-srcset')) {
element.setAttribute('srcset', element.getAttribute('data-srcset'));
}

if (element.getAttribute('data-background-image')) {
element.style.backgroundImage = 'url(\'' + element.getAttribute('data-background-image') + '\')';
}

if (element.getAttribute('data-toggle-class')) {
element.classList.toggle(element.getAttribute('data-toggle-class'));
}
Expand Down Expand Up @@ -91,9 +99,11 @@
if (selector instanceof Element) {
return [selector];
}

if (selector instanceof NodeList) {
return selector;
}

return root.querySelectorAll(selector);
};

Expand Down Expand Up @@ -126,10 +136,12 @@
if (isLoaded(elements[i])) {
continue;
}

if (observer) {
observer.observe(elements[i]);
continue;
}

load(elements[i]);
markAsLoaded(elements[i]);
loaded(elements[i]);
Expand Down
4 changes: 2 additions & 2 deletions dist/lozad.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-lock.json

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
Expand Up @@ -2,7 +2,7 @@
"name": "lozad",
"title": "lozad.js",
"description": "A light-weight JS library to lazy load any HTML element such as images, ads, videos etc.",
"version": "1.9.0",
"version": "1.10.0",
"homepage": "https://github.com/ApoorvSaxena/lozad.js",
"license": "MIT",
"scripts": {
Expand Down
5 changes: 4 additions & 1 deletion test/index.js
Expand Up @@ -158,7 +158,10 @@ describe('lozad', () => {
image.setAttribute('data-background-image', bgImageAttr)
observer.observe()
assert.strictEqual('true', image.dataset.loaded)
assert.strictEqual(image.style.backgroundImage, 'url(' + bgImageAttr + ')')
assert.strictEqual(
image.style.backgroundImage,
'url(' + bgImageAttr + ')'
)
})
})

Expand Down

0 comments on commit 62ceb52

Please sign in to comment.