Skip to content

Commit

Permalink
Iframe-loading: implement iframeLoadMode (fixes aFarkas#810)
Browse files Browse the repository at this point in the history
  • Loading branch information
aFarkas committed Oct 6, 2020
1 parent c0e0409 commit 08e4cab
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/lazysizes-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function l(window, document, Date) { // Pass in the windoe Date function also fo
//strictClass: 'lazystrict',
autosizesClass: 'lazyautosizes',
fastLoadedClass: 'ls-is-cached',
iframeLoadMode: 0,
srcAttr: 'data-src',
srcsetAttr: 'data-srcset',
sizesAttr: 'data-sizes',
Expand Down Expand Up @@ -435,9 +436,12 @@ function l(window, document, Date) { // Pass in the windoe Date function also fo
};

var changeIframeSrc = function(elem, src){
try {
var loadMode = elem.getAttribute('data-load-mode') || lazySizesCfg.iframeLoadMode;

// loadMode can be also a string!
if (loadMode == 0) {
elem.contentWindow.location.replace(src);
} catch(e){
} else if (loadMode == 1) {
elem.src = src;
}
};
Expand Down

0 comments on commit 08e4cab

Please sign in to comment.