Skip to content

Commit

Permalink
Merge branch 'hotfix/17.8.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok-cn committed May 24, 2022
2 parents 46d685d + 59a7a0e commit a0ba093
Show file tree
Hide file tree
Showing 13 changed files with 87 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Version 17

#### 17.8.2

- Fixed a bug which occurred if the network connection went off and on again after a LazyLoad instance was destroyed

#### 17.8.1

- Updated Typescript typings
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ Please note that the video poster can be lazily loaded too.

## 👩‍💻 Getting started - Script

The latest, recommended version of LazyLoad is **17.8.1**.
The latest, recommended version of LazyLoad is **17.8.2**.

Quickly understand how to upgrade from a previous version reading the [practical upgrade guide](UPGRADE.md).

Expand All @@ -184,7 +184,7 @@ Quickly understand how to upgrade from a previous version reading the [practical
The easiest way to use LazyLoad is to include the script from a CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.1/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.2/dist/lazyload.min.js"></script>
```

Then, in your javascript code:
Expand Down Expand Up @@ -225,7 +225,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.2/dist/lazyload.min.js"
></script>
```

Expand Down Expand Up @@ -259,7 +259,7 @@ Then include the script.
```html
<script
async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@17.8.2/dist/lazyload.min.js"
></script>
```

Expand Down
18 changes: 15 additions & 3 deletions dist/lazyload.amd.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,9 +761,18 @@ define(function () { 'use strict';
return;
}

window.addEventListener("online", function () {
instance._onlineHandler = function () {
retryLazyLoad(settings, instance);
});
};

window.addEventListener("online", instance._onlineHandler);
};
var resetOnlineCheck = function resetOnlineCheck(instance) {
if (!runningOnBrowser) {
return;
}

window.removeEventListener("online", instance._onlineHandler);
};

var LazyLoad = function LazyLoad(customSettings, elements) {
Expand Down Expand Up @@ -797,15 +806,18 @@ define(function () { 'use strict';
// Observer
if (this._observer) {
this._observer.disconnect();
} // Clean custom attributes on elements
} // Clean handlers


resetOnlineCheck(this); // Clean custom attributes on elements

queryElements(this._settings).forEach(function (element) {
deleteOriginalAttrs(element);
}); // Delete all internal props

delete this._observer;
delete this._settings;
delete this._onlineHandler;
delete this.loadingCount;
delete this.toLoadCount;
},
Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.amd.min.js

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions dist/lazyload.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ const getElementsToLoad = (elements, settings) =>

const retryLazyLoad = (settings, instance) => {
const errorElements = filterErrorElements(queryElements(settings));
errorElements.forEach(element => {
errorElements.forEach((element) => {
removeClass(element, settings.class_error);
resetStatus(element);
});
Expand All @@ -708,9 +708,17 @@ const setOnlineCheck = (settings, instance) => {
if (!runningOnBrowser) {
return;
}
window.addEventListener("online", () => {
instance._onlineHandler = () => {
retryLazyLoad(settings, instance);
});
};
window.addEventListener("online", instance._onlineHandler);
};

const resetOnlineCheck = (instance) => {
if (!runningOnBrowser) {
return;
}
window.removeEventListener("online", instance._onlineHandler);
};

const LazyLoad = function (customSettings, elements) {
Expand Down Expand Up @@ -745,13 +753,16 @@ LazyLoad.prototype = {
if (this._observer) {
this._observer.disconnect();
}
// Clean handlers
resetOnlineCheck(this);
// Clean custom attributes on elements
queryElements(this._settings).forEach((element) => {
deleteOriginalAttrs(element);
});
// Delete all internal props
delete this._observer;
delete this._settings;
delete this._onlineHandler;
delete this.loadingCount;
delete this.toLoadCount;
},
Expand Down
2 changes: 1 addition & 1 deletion dist/lazyload.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 15 additions & 3 deletions dist/lazyload.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -762,9 +762,18 @@ var LazyLoad = (function () {
return;
}

window.addEventListener("online", function () {
instance._onlineHandler = function () {
retryLazyLoad(settings, instance);
});
};

window.addEventListener("online", instance._onlineHandler);
};
var resetOnlineCheck = function resetOnlineCheck(instance) {
if (!runningOnBrowser) {
return;
}

window.removeEventListener("online", instance._onlineHandler);
};

var LazyLoad = function LazyLoad(customSettings, elements) {
Expand Down Expand Up @@ -798,15 +807,18 @@ var LazyLoad = (function () {
// Observer
if (this._observer) {
this._observer.disconnect();
} // Clean custom attributes on elements
} // Clean handlers


resetOnlineCheck(this); // Clean custom attributes on elements

queryElements(this._settings).forEach(function (element) {
deleteOriginalAttrs(element);
}); // Delete all internal props

delete this._observer;
delete this._settings;
delete this._onlineHandler;
delete this.loadingCount;
delete this.toLoadCount;
},
Expand Down
Loading

0 comments on commit a0ba093

Please sign in to comment.