From 23ade186cd74a336d018d0dca8062afc5c5e665d Mon Sep 17 00:00:00 2001 From: Christopher Darling Date: Mon, 1 Aug 2016 17:45:20 +0100 Subject: [PATCH] FIX object-fit plugin not working with picture markup --- plugins/object-fit/ls.object-fit.js | 2 +- plugins/object-fit/ls.object-fit.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/object-fit/ls.object-fit.js b/plugins/object-fit/ls.object-fit.js index 144dfc6d..2e2abd1e 100644 --- a/plugins/object-fit/ls.object-fit.js +++ b/plugins/object-fit/ls.object-fit.js @@ -59,7 +59,7 @@ var hideElement = element; var container = element.parentNode; - if(container.nodeName.toLowerCase() == 'PICTURE'){ + if(container.nodeName.toUpperCase() == 'PICTURE'){ hideElement = container; container = container.parentNode; } diff --git a/plugins/object-fit/ls.object-fit.min.js b/plugins/object-fit/ls.object-fit.min.js index e35f1650..e2caf835 100644 --- a/plugins/object-fit/ls.object-fit.min.js +++ b/plugins/object-fit/ls.object-fit.min.js @@ -1,2 +1,2 @@ /*! lazysizes - v2.0.0 */ -!function(){"use strict";function a(a){var b=getComputedStyle(a,null)||{},c=b.fontFamily||"",d=c.match(f)||"",e=d&&c.match(g)||"";return e&&(e=e[1]),{fit:d&&d[1]||"",position:i[e]||e||"center"}}function b(a,b){var c=a.cloneNode(!1),d=c.style,e=function(){var b=a.currentSrc||a.src;b&&(d.backgroundImage="url("+b+")")};a._lazysizesParentFit=b.fit,a.addEventListener("load",function(){lazySizes.rAF(e)},!0),c.addEventListener("load",function(){var a=c.currentSrc||c.src;a&&a!=h&&(c.src=h,c.srcset="")}),lazySizes.rAF(function(){var f=a,g=a.parentNode;"PICTURE"==g.nodeName.toLowerCase()&&(f=g,g=g.parentNode),lazySizes.rC(c,lazySizes.cfg.loadingClass),lazySizes.rC(c,lazySizes.cfg.loadedClass),lazySizes.rC(c,lazySizes.cfg.lazyClass),lazySizes.aC(c,lazySizes.cfg.objectFitClass||"lazysizes-display-clone"),c.src=h,c.srcset="",d.backgroundRepeat="no-repeat",d.backgroundPosition=b.position,d.backgroundSize=b.fit,f.style.display="none",a.setAttribute("data-parent-fit",b.fit),a.setAttribute("data-parent-container","prev"),g.insertBefore(c,f),a._lazysizesParentFit&&delete a._lazysizesParentFit,a.complete&&e()})}var c=document.createElement("a").style,d="objectFit"in c,e=d&&"objectPosition"in c,f=/object-fit["']*\s*:\s*["']*(contain|cover)/,g=/object-position["']*\s*:\s*["']*(.+?)(?=($|,|'|"|;))/,h="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",i={center:"center","50% 50%":"center"};d&&e||addEventListener("lazyunveilread",function(c){var e=c.target,f=a(e);!f.fit||d&&"center"==f.position||b(e,f)},!0)}(); \ No newline at end of file +!function(){"use strict";function a(a){var b=getComputedStyle(a,null)||{},c=b.fontFamily||"",d=c.match(f)||"",e=d&&c.match(g)||"";return e&&(e=e[1]),{fit:d&&d[1]||"",position:i[e]||e||"center"}}function b(a,b){var c=a.cloneNode(!1),d=c.style,e=function(){var b=a.currentSrc||a.src;b&&(d.backgroundImage="url("+b+")")};a._lazysizesParentFit=b.fit,a.addEventListener("load",function(){lazySizes.rAF(e)},!0),c.addEventListener("load",function(){var a=c.currentSrc||c.src;a&&a!=h&&(c.src=h,c.srcset="")}),lazySizes.rAF(function(){var f=a,g=a.parentNode;"PICTURE"==g.nodeName.toUpperCase()&&(f=g,g=g.parentNode),lazySizes.rC(c,lazySizes.cfg.loadingClass),lazySizes.rC(c,lazySizes.cfg.loadedClass),lazySizes.rC(c,lazySizes.cfg.lazyClass),lazySizes.aC(c,lazySizes.cfg.objectFitClass||"lazysizes-display-clone"),c.src=h,c.srcset="",d.backgroundRepeat="no-repeat",d.backgroundPosition=b.position,d.backgroundSize=b.fit,f.style.display="none",a.setAttribute("data-parent-fit",b.fit),a.setAttribute("data-parent-container","prev"),g.insertBefore(c,f),a._lazysizesParentFit&&delete a._lazysizesParentFit,a.complete&&e()})}var c=document.createElement("a").style,d="objectFit"in c,e=d&&"objectPosition"in c,f=/object-fit["']*\s*:\s*["']*(contain|cover)/,g=/object-position["']*\s*:\s*["']*(.+?)(?=($|,|'|"|;))/,h="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",i={center:"center","50% 50%":"center"};d&&e||addEventListener("lazyunveilread",function(c){var e=c.target,f=a(e);!f.fit||d&&"center"==f.position||b(e,f)},!0)}(); \ No newline at end of file