Skip to content

Commit 79575e6

Browse files
committed
Resolves issue with supported browsers.
1 parent f754160 commit 79575e6

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

dist/yall.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ function yall (options) {
7171
// member of an array. This abstraction eliminates that repetitive code.
7272
const yallApplyFn = (items, fn) => {
7373
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
74-
if (noPolyfill) {
75-
fn(items[itemIndex]);
74+
if(win[io] && fn instanceof win[io]) {
75+
fn.observe(items[itemIndex]);
7676
} else {
77-
fn instanceof win[io] ? fn.observe(items[itemIndex]) : fn(items[itemIndex]);
78-
}
77+
fn(items[itemIndex]);
78+
}
7979
}
8080
};
8181

dist/yall.min.js

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

dist/yall.min.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export default function(e){const t=(e=e||{}).lazyClass||"lazy",o=e.lazyBackgroundClass||"lazy-bg",n="idleLoadTimeout"in e?e.idleLoadTimeout:200,s=e.observeChanges||!1,i=e.events||{},r=e.noPolyfill||!1,a=window,l="requestIdleCallback",d="IntersectionObserver",c=["srcset","src","poster"],u=[],b=(e,n)=>u.slice.call((n||document).querySelectorAll(e||"img."+t+",video."+t+",iframe."+t+",."+o)),v=t=>{const n=t.parentNode;"PICTURE"==n.nodeName&&m(b("source",n),f),"VIDEO"==t.nodeName&&m(b("source",t),f),f(t),t.autoplay&&t.load();const s=t.classList;s.contains(o)&&(s.remove(o),s.add(e.lazyBackgroundLoaded||"lazy-bg-loaded"))},g=e=>{for(let t in i)e.addEventListener(t,i[t].listener||i[t],i[t].options||void 0)},f=e=>{for(let o in c)c[o]in e.dataset&&a.requestAnimationFrame(()=>{e.setAttribute(c[o],e.dataset[c[o]]),e.classList.remove(t)})},m=(e,t)=>{for(let o=0;o<e.length;o++)r?t(e[o]):t instanceof a[d]?t.observe(e[o]):t(e[o])},y=e=>{if(e.isIntersecting||e.intersectionRatio){const t=e.target;l in a&&n?a[l](()=>{v(t)},{timeout:n}):v(t),z.unobserve(t),(L=L.filter(e=>e!=t)).length||s||z.disconnect()}},h=e=>{L.indexOf(e)<0&&(L.push(e),g(e),z.observe(e))},p=t=>{new MutationObserver(()=>{m(b(),h)}).observe(t,e.mutationObserverOptions||{childList:!0,subtree:!0})};let L=b();if(/baidu|(?:google|bing|yandex|duckduck)bot/i.test(navigator.userAgent))m(L,v);else if(d in a&&d+"Entry"in a){var z=new a[d](e=>{m(e,y)},{rootMargin:("threshold"in e?e.threshold:200)+"px 0%"});m(L,g),m(L,z),s&&m(b(e.observeRootSelector||"body"),p)}else r&&(m(L,g),m(L,v))}
1+
export default function(e){const t=(e=e||{}).lazyClass||"lazy",o=e.lazyBackgroundClass||"lazy-bg",n="idleLoadTimeout"in e?e.idleLoadTimeout:200,s=e.observeChanges||!1,i=e.events||{},r=e.noPolyfill||!1,a=window,l="requestIdleCallback",d="IntersectionObserver",c=["srcset","src","poster"],u=[],b=(e,n)=>u.slice.call((n||document).querySelectorAll(e||"img."+t+",video."+t+",iframe."+t+",."+o)),v=t=>{const n=t.parentNode;"PICTURE"==n.nodeName&&m(b("source",n),f),"VIDEO"==t.nodeName&&m(b("source",t),f),f(t),t.autoplay&&t.load();const s=t.classList;s.contains(o)&&(s.remove(o),s.add(e.lazyBackgroundLoaded||"lazy-bg-loaded"))},g=e=>{for(let t in i)e.addEventListener(t,i[t].listener||i[t],i[t].options||void 0)},f=e=>{for(let o in c)c[o]in e.dataset&&a.requestAnimationFrame(()=>{e.setAttribute(c[o],e.dataset[c[o]]),e.classList.remove(t)})},m=(e,t)=>{for(let o=0;o<e.length;o++)a[d]&&t instanceof a[d]?t.observe(e[o]):t(e[o])},y=e=>{if(e.isIntersecting||e.intersectionRatio){const t=e.target;l in a&&n?a[l](()=>{v(t)},{timeout:n}):v(t),z.unobserve(t),(L=L.filter(e=>e!=t)).length||s||z.disconnect()}},h=e=>{L.indexOf(e)<0&&(L.push(e),g(e),z.observe(e))},p=t=>{new MutationObserver(()=>{m(b(),h)}).observe(t,e.mutationObserverOptions||{childList:!0,subtree:!0})};let L=b();if(/baidu|(?:google|bing|yandex|duckduck)bot/i.test(navigator.userAgent))m(L,v);else if(d in a&&d+"Entry"in a){var z=new a[d](e=>{m(e,y)},{rootMargin:("threshold"in e?e.threshold:200)+"px 0%"});m(L,g),m(L,z),s&&m(b(e.observeRootSelector||"body"),p)}else r&&(m(L,g),m(L,v))}

src/yall.mjs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ export default function (options) {
6969
// member of an array. This abstraction eliminates that repetitive code.
7070
const yallApplyFn = (items, fn) => {
7171
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
72-
if (noPolyfill) {
73-
fn(items[itemIndex]);
72+
if(win[io] && fn instanceof win[io]) {
73+
fn.observe(items[itemIndex]);
7474
} else {
75-
fn instanceof win[io] ? fn.observe(items[itemIndex]) : fn(items[itemIndex]);
76-
}
75+
fn(items[itemIndex]);
76+
}
7777
}
7878
};
7979

test/js/yall.min.js

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

0 commit comments

Comments
 (0)