Skip to content

Commit 62ceb52

Browse files
committed
1.10.0 release
1 parent 3ae5f9b commit 62ceb52

File tree

6 files changed

+36
-9
lines changed

6 files changed

+36
-9
lines changed

Diff for: dist/lozad.es.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! lozad.js - v1.9.0 - 2019-06-06
1+
/*! lozad.js - v1.10.0 - 2019-06-06
22
* https://github.com/ApoorvSaxena/lozad.js
33
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */
44

@@ -19,11 +19,14 @@ const defaultConfig = {
1919
if (isIE && element.getAttribute('data-iesrc')) {
2020
img.src = element.getAttribute('data-iesrc');
2121
}
22+
2223
if (element.getAttribute('data-alt')) {
2324
img.alt = element.getAttribute('data-alt');
2425
}
25-
element.appendChild(img);
26+
27+
element.append(img);
2628
}
29+
2730
if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
2831
if (element.children) {
2932
const childs = element.children;
@@ -34,18 +37,23 @@ const defaultConfig = {
3437
childs[i].src = childSrc;
3538
}
3639
}
40+
3741
element.load();
3842
}
3943
}
44+
4045
if (element.getAttribute('data-src')) {
4146
element.src = element.getAttribute('data-src');
4247
}
48+
4349
if (element.getAttribute('data-srcset')) {
4450
element.setAttribute('srcset', element.getAttribute('data-srcset'));
4551
}
52+
4653
if (element.getAttribute('data-background-image')) {
4754
element.style.backgroundImage = `url('${element.getAttribute('data-background-image')}')`;
4855
}
56+
4957
if (element.getAttribute('data-toggle-class')) {
5058
element.classList.toggle(element.getAttribute('data-toggle-class'));
5159
}
@@ -77,9 +85,11 @@ const getElements = (selector, root = document) => {
7785
if (selector instanceof Element) {
7886
return [selector]
7987
}
88+
8089
if (selector instanceof NodeList) {
8190
return selector
8291
}
92+
8393
return root.querySelectorAll(selector)
8494
};
8595

@@ -103,10 +113,12 @@ function lozad (selector = '.lozad', options = {}) {
103113
if (isLoaded(elements[i])) {
104114
continue
105115
}
116+
106117
if (observer) {
107118
observer.observe(elements[i]);
108119
continue
109120
}
121+
110122
load(elements[i]);
111123
markAsLoaded(elements[i]);
112124
loaded(elements[i]);

Diff for: dist/lozad.js

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! lozad.js - v1.9.0 - 2019-06-06
1+
/*! lozad.js - v1.10.0 - 2019-06-06
22
* https://github.com/ApoorvSaxena/lozad.js
33
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */
44

@@ -27,11 +27,14 @@
2727
if (isIE && element.getAttribute('data-iesrc')) {
2828
img.src = element.getAttribute('data-iesrc');
2929
}
30+
3031
if (element.getAttribute('data-alt')) {
3132
img.alt = element.getAttribute('data-alt');
3233
}
33-
element.appendChild(img);
34+
35+
element.append(img);
3436
}
37+
3538
if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
3639
if (element.children) {
3740
var childs = element.children;
@@ -42,18 +45,23 @@
4245
childs[i].src = childSrc;
4346
}
4447
}
48+
4549
element.load();
4650
}
4751
}
52+
4853
if (element.getAttribute('data-src')) {
4954
element.src = element.getAttribute('data-src');
5055
}
56+
5157
if (element.getAttribute('data-srcset')) {
5258
element.setAttribute('srcset', element.getAttribute('data-srcset'));
5359
}
60+
5461
if (element.getAttribute('data-background-image')) {
5562
element.style.backgroundImage = 'url(\'' + element.getAttribute('data-background-image') + '\')';
5663
}
64+
5765
if (element.getAttribute('data-toggle-class')) {
5866
element.classList.toggle(element.getAttribute('data-toggle-class'));
5967
}
@@ -91,9 +99,11 @@
9199
if (selector instanceof Element) {
92100
return [selector];
93101
}
102+
94103
if (selector instanceof NodeList) {
95104
return selector;
96105
}
106+
97107
return root.querySelectorAll(selector);
98108
};
99109

@@ -126,10 +136,12 @@
126136
if (isLoaded(elements[i])) {
127137
continue;
128138
}
139+
129140
if (observer) {
130141
observer.observe(elements[i]);
131142
continue;
132143
}
144+
133145
load(elements[i]);
134146
markAsLoaded(elements[i]);
135147
loaded(elements[i]);

Diff for: dist/lozad.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "lozad",
33
"title": "lozad.js",
44
"description": "A light-weight JS library to lazy load any HTML element such as images, ads, videos etc.",
5-
"version": "1.9.0",
5+
"version": "1.10.0",
66
"homepage": "https://github.com/ApoorvSaxena/lozad.js",
77
"license": "MIT",
88
"scripts": {

Diff for: test/index.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,10 @@ describe('lozad', () => {
158158
image.setAttribute('data-background-image', bgImageAttr)
159159
observer.observe()
160160
assert.strictEqual('true', image.dataset.loaded)
161-
assert.strictEqual(image.style.backgroundImage, 'url(' + bgImageAttr + ')')
161+
assert.strictEqual(
162+
image.style.backgroundImage,
163+
'url(' + bgImageAttr + ')'
164+
)
162165
})
163166
})
164167

0 commit comments

Comments
 (0)