Skip to content

Commit

Permalink
Implemented restore_on_error
Browse files Browse the repository at this point in the history
  • Loading branch information
verlok committed Apr 10, 2022
1 parent 4ffd5bf commit 1f2b4da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const defaultSettings = {
callback_error: null,
callback_finish: null,
callback_cancel: null,
use_native: false
use_native: false,
restore_on_error: false,
};

export const getExtendedSettings = (customSettings) => {
Expand Down
2 changes: 2 additions & 0 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
haveElementsToLoad,
isSomethingLoading
} from "./counters";
import { attrsSrcSrcsetSizes, restoreOriginalAttrs } from "./originalAttributes";

const elementsWithLoadEvent = ["IMG", "IFRAME", "VIDEO", "OBJECT"];
export const hasLoadEvent = (element) => elementsWithLoadEvent.indexOf(element.tagName) > -1;
Expand Down Expand Up @@ -77,6 +78,7 @@ export const errorHandler = (event, element, settings, instance) => {
addClass(element, settings.class_error);
setStatus(element, statusError);
safeCallback(settings.callback_error, element, instance);
if (settings.restore_on_error) restoreOriginalAttrs(element, attrsSrcSrcsetSizes);
if (!goingNative) checkFinish(settings, instance);
};

Expand Down

0 comments on commit 1f2b4da

Please sign in to comment.