Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

loading-attribute-polyfill

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

loading-attribute-polyfill - npm Package Compare versions

Comparing version 2.0.0-beta.1 to 2.0.0-rc.0

2

bower.json

@@ -35,3 +35,3 @@ {

".gitignore",
".huskyrc",
".husky",
"commitlint.config.js",

@@ -38,0 +38,0 @@ "wdio.conf-crossbrowsertesting.js"

@@ -9,2 +9,19 @@ # Changelog

## [2.0.0-rc.0] - 2021-03-22
### Added
- GitHub's static analysis engine CodeQL to check against our repository's source code to find security vulnerabilities
- Dependabot to ensure devDependencies are up to date ([!106](https://github.com/mfranzke/loading-attribute-polyfill/pull/106))
### Changed
- devDependency: bump husky from 5.1.2 to version 5.1.3
- devDependency: bump html-validate from 4.6.0 to 4.7.1 (commit [801b314](https://github.com/mfranzke/loading-attribute-polyfill/commit/801b314), [!105](https://github.com/mfranzke/loading-attribute-polyfill/pull/105) and [!109](https://github.com/mfranzke/loading-attribute-polyfill/pull/109))
### Fixed
- testing: updated the tools and removed some old code to make crossbrowsertesting.com work again ([!100](https://github.com/mfranzke/loading-attribute-polyfill/pull/100))
- browsers capabilities: we need to differentiate in between image and iframe capability, as Firefox only supports images for now, but not iframes
## [2.0.0-beta.1] - 2021-03-04

@@ -11,0 +28,0 @@

@@ -1,2 +0,2 @@

var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype&&"loading"in HTMLIFrameElement.prototype,a="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),n(r)}})},t));var o="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function n(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function i(t){var o=document.createElement("div");for(o.innerHTML=function(t){var o=t.textContent||t.innerHTML,n="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((o.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((o.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return!r&&a&&(o=void 0===e?o.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(o=o.replace("<source",'<source srcset="'+n+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+n+'" data-lazy-src=')),o}(t);o.firstChild;){var n=o.firstChild;if(!r&&a&&void 0!==e&&n.tagName&&("img"===n.tagName.toLowerCase()||"picture"===n.tagName.toLowerCase()||"iframe"===n.tagName.toLowerCase())){var i="picture"===n.tagName.toLowerCase()?o.querySelector("img"):n;e.observe(i)}t.parentNode.insertBefore(n,t)}t.parentNode.removeChild(t)}var c=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return i(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){n(e)})})};/comp|inter/.test(document.readyState)?o(c):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){o(c)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&c()}),module.exports={prepareElement:i};
var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype,a="loading"in HTMLIFrameElement.prototype,o="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),i(r)}})},t));var n="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function i(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function c(t){var n=document.createElement("div");for(n.innerHTML=function(t){var n=t.textContent||t.innerHTML,i="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((n.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((n.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return(/<img/gim.test(n)&&!r||/<iframe/gim.test(n)&&!a)&&o&&(n=void 0===e?n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+i+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+i+'" data-lazy-src=')),n}(t);n.firstChild;){var i=n.firstChild;if(o&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!r||"iframe"===i.tagName.toLowerCase()&&!a)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}t.parentNode.insertBefore(i,t)}t.parentNode.removeChild(t)}var s=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return c(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){i(e)})})};/comp|inter/.test(document.readyState)?n(s):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){n(s)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&s()}),module.exports={prepareElement:c};
//# sourceMappingURL=loading-attribute-polyfill.js.map

@@ -1,2 +0,2 @@

var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype&&"loading"in HTMLIFrameElement.prototype,a="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),n(r)}})},t));var o="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function n(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function i(t){var o=document.createElement("div");for(o.innerHTML=function(t){var o=t.textContent||t.innerHTML,n="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((o.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((o.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return!r&&a&&(o=void 0===e?o.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(o=o.replace("<source",'<source srcset="'+n+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+n+'" data-lazy-src=')),o}(t);o.firstChild;){var n=o.firstChild;if(!r&&a&&void 0!==e&&n.tagName&&("img"===n.tagName.toLowerCase()||"picture"===n.tagName.toLowerCase()||"iframe"===n.tagName.toLowerCase())){var i="picture"===n.tagName.toLowerCase()?o.querySelector("img"):n;e.observe(i)}t.parentNode.insertBefore(n,t)}t.parentNode.removeChild(t)}let c=()=>{document.querySelectorAll("noscript.loading-lazy").forEach(e=>i(e)),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){n(e)})})};/comp|inter/.test(document.readyState)?o(c):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){o(c)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&c()});const s={prepareElement:i};export default s;
var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype,a="loading"in HTMLIFrameElement.prototype,o="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),i(r)}})},t));var n="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function i(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function c(t){var n=document.createElement("div");for(n.innerHTML=function(t){var n=t.textContent||t.innerHTML,i="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((n.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((n.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return(/<img/gim.test(n)&&!r||/<iframe/gim.test(n)&&!a)&&o&&(n=void 0===e?n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+i+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+i+'" data-lazy-src=')),n}(t);n.firstChild;){var i=n.firstChild;if(o&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!r||"iframe"===i.tagName.toLowerCase()&&!a)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}t.parentNode.insertBefore(i,t)}t.parentNode.removeChild(t)}let s=()=>{document.querySelectorAll("noscript.loading-lazy").forEach(e=>c(e)),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){i(e)})})};/comp|inter/.test(document.readyState)?n(s):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){n(s)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&s()});const d={prepareElement:c};export default d;
//# sourceMappingURL=loading-attribute-polyfill.modern.js.map

@@ -1,2 +0,2 @@

var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype&&"loading"in HTMLIFrameElement.prototype,a="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),n(r)}})},t));var o="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function n(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function i(t){var o=document.createElement("div");for(o.innerHTML=function(t){var o=t.textContent||t.innerHTML,n="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((o.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((o.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return!r&&a&&(o=void 0===e?o.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(o=o.replace("<source",'<source srcset="'+n+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+n+'" data-lazy-src=')),o}(t);o.firstChild;){var n=o.firstChild;if(!r&&a&&void 0!==e&&n.tagName&&("img"===n.tagName.toLowerCase()||"picture"===n.tagName.toLowerCase()||"iframe"===n.tagName.toLowerCase())){var i="picture"===n.tagName.toLowerCase()?o.querySelector("img"):n;e.observe(i)}t.parentNode.insertBefore(n,t)}t.parentNode.removeChild(t)}var c=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return i(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){n(e)})})};/comp|inter/.test(document.readyState)?o(c):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){o(c)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&c()});var s={prepareElement:i};export default s;
var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype,a="loading"in HTMLIFrameElement.prototype,o="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),i(r)}})},t));var n="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function i(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function c(t){var n=document.createElement("div");for(n.innerHTML=function(t){var n=t.textContent||t.innerHTML,i="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((n.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((n.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return(/<img/gim.test(n)&&!r||/<iframe/gim.test(n)&&!a)&&o&&(n=void 0===e?n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+i+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+i+'" data-lazy-src=')),n}(t);n.firstChild;){var i=n.firstChild;if(o&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!r||"iframe"===i.tagName.toLowerCase()&&!a)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}t.parentNode.insertBefore(i,t)}t.parentNode.removeChild(t)}var s=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return c(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){i(e)})})};/comp|inter/.test(document.readyState)?n(s):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){n(s)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&s()});var d={prepareElement:c};export default d;
//# sourceMappingURL=loading-attribute-polyfill.module.js.map

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).loadingAttributePolyfill=t()}(this,function(){var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype&&"loading"in HTMLIFrameElement.prototype,a="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),n(r)}})},t));var o="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function n(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function i(t){var o=document.createElement("div");for(o.innerHTML=function(t){var o=t.textContent||t.innerHTML,n="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((o.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((o.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return!r&&a&&(o=void 0===e?o.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(o=o.replace("<source",'<source srcset="'+n+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+n+'" data-lazy-src=')),o}(t);o.firstChild;){var n=o.firstChild;if(!r&&a&&void 0!==e&&n.tagName&&("img"===n.tagName.toLowerCase()||"picture"===n.tagName.toLowerCase()||"iframe"===n.tagName.toLowerCase())){var i="picture"===n.tagName.toLowerCase()?o.querySelector("img"):n;e.observe(i)}t.parentNode.insertBefore(n,t)}t.parentNode.removeChild(t)}var c=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return i(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){n(e)})})};return/comp|inter/.test(document.readyState)?o(c):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){o(c)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&c()}),{prepareElement:i}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e||self).loadingAttributePolyfill=t()}(this,function(){var e,t={rootMargin:"0px 0px 256px 0px",threshold:.01,lazyImage:'img[loading="lazy"]',lazyIframe:'iframe[loading="lazy"]'},r="loading"in HTMLImageElement.prototype,a="loading"in HTMLIFrameElement.prototype,o="onscroll"in window;window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(e=new IntersectionObserver(function(e,t){e.forEach(function(e){if(0!==e.intersectionRatio){var r=e.target;t.unobserve(r),i(r)}})},t));var n="requestAnimationFrame"in window?window.requestAnimationFrame:function(e){e()};function i(e){var t,r,a=[];"picture"===e.parentNode.tagName.toLowerCase()&&((r=(t=e.parentNode).querySelector("source[data-lazy-remove]"))&&t.removeChild(r),a=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),a.push(e),a.forEach(function(e){e.hasAttribute("data-lazy-srcset")&&(e.setAttribute("srcset",e.getAttribute("data-lazy-srcset")),e.removeAttribute("data-lazy-srcset"))}),e.setAttribute("src",e.getAttribute("data-lazy-src")),e.removeAttribute("data-lazy-src")}function c(t){var n=document.createElement("div");for(n.innerHTML=function(t){var n=t.textContent||t.innerHTML,i="data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 viewBox=%270 0 "+((n.match(/width=['"](\d+)['"]/)||!1)[1]||1)+" "+((n.match(/height=['"](\d+)['"]/)||!1)[1]||1)+"%27%3E%3C/svg%3E";return(/<img/gim.test(n)&&!r||/<iframe/gim.test(n)&&!a)&&o&&(n=void 0===e?n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+i+'" data-lazy-remove="true"></source>\n<source')).replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+i+'" data-lazy-src=')),n}(t);n.firstChild;){var i=n.firstChild;if(o&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!r||"iframe"===i.tagName.toLowerCase()&&!a)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}t.parentNode.insertBefore(i,t)}t.parentNode.removeChild(t)}var d=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return c(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll(t.lazyImage+"[data-lazy-src],"+t.lazyIframe+"[data-lazy-src]").forEach(function(e){i(e)})})};return/comp|inter/.test(document.readyState)?n(d):"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){n(d)}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&d()}),{prepareElement:c}});
//# sourceMappingURL=loading-attribute-polyfill.umd.js.map

@@ -25,5 +25,6 @@ /*

var capabilities = {
loading:
'loading' in HTMLImageElement.prototype &&
'loading' in HTMLIFrameElement.prototype,
loading: {
image: 'loading' in HTMLImageElement.prototype,
iframe: 'loading' in HTMLIFrameElement.prototype,
},
scrolling: 'onscroll' in window,

@@ -165,3 +166,8 @@ };

if (!capabilities.loading && capabilities.scrolling) {
// Test for whether it's image or iframe content, their support by the browser and regarding the scrolling capability
if (
((/<img/gim.test(lazyAreaHtml) && !capabilities.loading.image) ||
(/<iframe/gim.test(lazyAreaHtml) && !capabilities.loading.iframe)) &&
capabilities.scrolling
) {
// Check for IntersectionObserver support

@@ -211,9 +217,10 @@ if (typeof intersectionObserver === 'undefined') {

if (
!capabilities.loading &&
capabilities.scrolling &&
typeof intersectionObserver !== 'undefined' &&
actualChild.tagName &&
(actualChild.tagName.toLowerCase() === 'img' ||
actualChild.tagName.toLowerCase() === 'picture' ||
actualChild.tagName.toLowerCase() === 'iframe')
(((actualChild.tagName.toLowerCase() === 'img' ||
actualChild.tagName.toLowerCase() === 'picture') &&
!capabilities.loading.image) ||
(actualChild.tagName.toLowerCase() === 'iframe' &&
!capabilities.loading.iframe))
) {

@@ -220,0 +227,0 @@ var observedElement =

{
"name": "loading-attribute-polyfill",
"version": "2.0.0-beta.1",
"version": "2.0.0-rc.0",
"description": "Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.",

@@ -31,13 +31,13 @@ "source": "./loading-attribute-polyfill.js",

},
"homepage": "https://github.com/mfranzke/loading-attribute-polyfill",
"homepage": "https://mfranzke.github.io/loading-attribute-polyfill/demo/",
"devDependencies": {
"@commitlint/cli": "^12.0.1",
"@commitlint/config-conventional": "^12.0.1",
"@wdio/cli": "^6.1.12",
"@wdio/dot-reporter": "^6.1.9",
"@wdio/local-runner": "^6.1.12",
"@wdio/mocha-framework": "^6.1.8",
"@wdio/sync": "^6.1.8",
"html-validate": "^4.6.0",
"husky": "^5.1.2",
"@wdio/cli": "^7.1.0",
"@wdio/dot-reporter": "^7.0.7",
"@wdio/local-runner": "^7.1.0",
"@wdio/mocha-framework": "^7.0.7",
"@wdio/sync": "^7.1.0",
"html-validate": "^4.6.1",
"husky": "^5.1.3",
"microbundle": "^0.13.0",

@@ -47,3 +47,2 @@ "npm-run-all": "^4.1.5",

"pretty-quick": "^3.1.0",
"webdriverio": "^6.12.1",
"xo": "^0.38.2"

@@ -55,2 +54,3 @@ },

"validate:html": "html-validate demo/index.html",
"test:wdio": "wdio run wdio.conf-crossbrowsertesting.js",
"build": "microbundle",

@@ -57,0 +57,0 @@ "dev": "microbundle watch",

@@ -9,2 +9,3 @@ # loading="lazy" attribute polyfill

[![Known Vulnerabilities](https://snyk.io/test/github/mfranzke/loading-attribute-polyfill/badge.svg?targetFile=package.json)](https://snyk.io/test/github/mfranzke/loading-attribute-polyfill?targetFile=package.json)
[![CodeQL](https://github.com/mfranzke/loading-attribute-polyfill/actions/workflows/codeql-analysis.yml/badge.svg?branch=master)](https://github.com/mfranzke/loading-attribute-polyfill/actions/workflows/codeql-analysis.yml)
[![dependencies Status](https://david-dm.org/mfranzke/loading-attribute-polyfill/status.svg "Count of dependencies")](https://david-dm.org/mfranzke/loading-attribute-polyfill "loading-attribute polyfill – on david-dm")

@@ -11,0 +12,0 @@ [![loading-attribute-polyfill on Npmjs](https://img.shields.io/npm/v/loading-attribute-polyfill.svg?color=rgb%28237%2C%2028%2C%2036%29 "npm version")](https://npmjs.com/package/loading-attribute-polyfill 'loading="lazy"-attribute polyfill – on NPM')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc