loading-attribute-polyfill
Advanced tools
Comparing version 2.0.2 to 2.1.0
@@ -18,2 +18,12 @@ # Changelog | ||
## [2.1.0] - 2022-05-15 | ||
### Added | ||
- `browser` field to `package.json` instead of `main` entry again | ||
### Changed | ||
- Updated `devDependencies` | ||
## [2.0.2] - 2022-04-10 | ||
@@ -20,0 +30,0 @@ |
@@ -1,2 +0,2 @@ | ||
const e="loading"in HTMLImageElement.prototype,t="loading"in HTMLIFrameElement.prototype,r="onscroll"in window;let a;function o(e){let t=[];"picture"===e.parentNode.tagName.toLowerCase()&&(function(e){const t=e.querySelector("source[data-lazy-remove]");t&&e.removeChild(t)}(e.parentNode),t=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),t.push(e),t.forEach(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 n(o){const n=document.createElement("div");for(n.innerHTML=function(o){let n=o.textContent||o.innerHTML;const c="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)&&!e||/<iframe/gim.test(n)&&!t)&&r&&(void 0===a?n=n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+c+'" data-lazy-remove="true"></source>\n<source'),n=n.replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+c+'" data-lazy-src='))),n}(o);n.firstChild;){const c=n.firstChild;if(r&&void 0!==a&&c.tagName&&(("img"===c.tagName.toLowerCase()||"picture"===c.tagName.toLowerCase())&&!e||"iframe"===c.tagName.toLowerCase()&&!t)){const e="picture"===c.tagName.toLowerCase()?n.querySelector("img"):c;a.observe(e)}o.parentNode.insertBefore(c,o)}o.parentNode.removeChild(o)}window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(a=new IntersectionObserver(function(e,t){e.forEach(e=>{if(0===e.intersectionRatio)return;const r=e.target;t.unobserve(r),o(r)})},{rootMargin:"0px 0px 256px 0px",threshold:.01}));const c=()=>{document.querySelectorAll("noscript.loading-lazy").forEach(e=>n(e)),void 0!==window.matchMedia&&window.matchMedia("print").addListener(e=>{e.matches&&document.querySelectorAll('img[loading="lazy"][data-lazy-src],iframe[loading="lazy"][data-lazy-src]').forEach(e=>{o(e)})})};/comp|inter/.test(document.readyState)?c():"addEventListener"in document?document.addEventListener("DOMContentLoaded",()=>{c()}):document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&c()});const s={prepareElement:n};export default s; | ||
const e="loading"in HTMLImageElement.prototype,t="loading"in HTMLIFrameElement.prototype,r="onscroll"in window;let a;function o(e){let t=[];"picture"===e.parentNode.tagName.toLowerCase()&&(function(e){const t=e.querySelector("source[data-lazy-remove]");t&&e.removeChild(t)}(e.parentNode),t=Array.prototype.slice.call(e.parentNode.querySelectorAll("source"))),t.push(e),t.forEach(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 n(o){const n=document.createElement("div");for(n.innerHTML=function(o){let n=o.textContent||o.innerHTML;const c="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)&&!e||/<iframe/gim.test(n)&&!t)&&r&&(void 0===a?n=n.replace(/(?:\r\n|\r|\n|\t| )src=/g,' lazyload="1" src='):(n=n.replace("<source",'<source srcset="'+c+'" data-lazy-remove="true"></source>\n<source'),n=n.replace(/(?:\r\n|\r|\n|\t| )srcset=/g," data-lazy-srcset=").replace(/(?:\r\n|\r|\n|\t| )src=/g,' src="'+c+'" data-lazy-src='))),n}(o);n.firstChild;){const c=n.firstChild;if(r&&void 0!==a&&c.tagName&&(("img"===c.tagName.toLowerCase()||"picture"===c.tagName.toLowerCase())&&!e||"iframe"===c.tagName.toLowerCase()&&!t)){const e="picture"===c.tagName.toLowerCase()?n.querySelector("img"):c;a.observe(e)}o.parentNode.insertBefore(c,o)}o.parentNode.removeChild(o)}window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),"IntersectionObserver"in window&&(a=new IntersectionObserver(function(e,t){e.forEach(e=>{if(0===e.intersectionRatio)return;const r=e.target;t.unobserve(r),o(r)})},{rootMargin:"0px 0px 256px 0px",threshold:.01}));const c=()=>{document.querySelectorAll("noscript.loading-lazy").forEach(e=>n(e)),void 0!==window.matchMedia&&window.matchMedia("print").addListener(e=>{e.matches&&document.querySelectorAll('img[loading="lazy"][data-lazy-src],iframe[loading="lazy"][data-lazy-src]').forEach(e=>{o(e)})})};/comp|inter/.test(document.readyState)?c():"addEventListener"in document?document.addEventListener("DOMContentLoaded",()=>{c()}):document.attachEvent("onreadystatechange",()=>{"complete"===document.readyState&&c()});const s={prepareElement:n};export{s as default}; | ||
//# sourceMappingURL=loading-attribute-polyfill.modern.js.map |
@@ -1,2 +0,2 @@ | ||
var e,t="loading"in HTMLImageElement.prototype,r="loading"in HTMLIFrameElement.prototype,a="onscroll"in window;function o(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 n(o){var n=document.createElement("div");for(n.innerHTML=function(o){var n=o.textContent||o.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)&&!t||/<iframe/gim.test(n)&&!r)&&a&&(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}(o);n.firstChild;){var i=n.firstChild;if(a&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!t||"iframe"===i.tagName.toLowerCase()&&!r)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}o.parentNode.insertBefore(i,o)}o.parentNode.removeChild(o)}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),o(r)}})},{rootMargin:"0px 0px 256px 0px",threshold:.01}));var i=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return n(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll('img[loading="lazy"][data-lazy-src],iframe[loading="lazy"][data-lazy-src]').forEach(function(e){o(e)})})};/comp|inter/.test(document.readyState)?i():"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){i()}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&i()});var c={prepareElement:n};export default c; | ||
var e,t="loading"in HTMLImageElement.prototype,r="loading"in HTMLIFrameElement.prototype,a="onscroll"in window;function o(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 n(o){var n=document.createElement("div");for(n.innerHTML=function(o){var n=o.textContent||o.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)&&!t||/<iframe/gim.test(n)&&!r)&&a&&(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}(o);n.firstChild;){var i=n.firstChild;if(a&&void 0!==e&&i.tagName&&(("img"===i.tagName.toLowerCase()||"picture"===i.tagName.toLowerCase())&&!t||"iframe"===i.tagName.toLowerCase()&&!r)){var c="picture"===i.tagName.toLowerCase()?n.querySelector("img"):i;e.observe(c)}o.parentNode.insertBefore(i,o)}o.parentNode.removeChild(o)}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),o(r)}})},{rootMargin:"0px 0px 256px 0px",threshold:.01}));var i=function(){document.querySelectorAll("noscript.loading-lazy").forEach(function(e){return n(e)}),void 0!==window.matchMedia&&window.matchMedia("print").addListener(function(e){e.matches&&document.querySelectorAll('img[loading="lazy"][data-lazy-src],iframe[loading="lazy"][data-lazy-src]').forEach(function(e){o(e)})})};/comp|inter/.test(document.readyState)?i():"addEventListener"in document?document.addEventListener("DOMContentLoaded",function(){i()}):document.attachEvent("onreadystatechange",function(){"complete"===document.readyState&&i()});var c={prepareElement:n};export{c as default}; | ||
//# sourceMappingURL=loading-attribute-polyfill.module.js.map |
{ | ||
"name": "loading-attribute-polyfill", | ||
"version": "2.0.2", | ||
"version": "2.1.0", | ||
"description": "Fast and lightweight dependency-free vanilla JavaScript polyfill for native lazy loading / the awesome loading='lazy'-attribute.", | ||
"source": "./src/loading-attribute-polyfill.js", | ||
"browser": "./dist/loading-attribute-polyfill.js", | ||
"esmodule": "./dist/loading-attribute-polyfill.modern.js", | ||
@@ -35,9 +36,9 @@ "module": "./dist/loading-attribute-polyfill.module.js", | ||
"@commitlint/config-conventional": "^16.0.0", | ||
"@wdio/cli": "^7.19.3", | ||
"@wdio/dot-reporter": "^7.19.1", | ||
"@wdio/local-runner": "^7.19.3", | ||
"@wdio/mocha-framework": "^7.19.3", | ||
"html-validate": "^6.0.2", | ||
"husky": "^7.0.1", | ||
"microbundle": "^0.14.1", | ||
"@wdio/cli": "^7.19.5", | ||
"@wdio/dot-reporter": "^7.19.5", | ||
"@wdio/local-runner": "^7.19.5", | ||
"@wdio/mocha-framework": "^7.19.5", | ||
"html-validate": "^7.0.0", | ||
"husky": "^8.0.0", | ||
"microbundle": "^0.15.0", | ||
"np": "^7.5.0", | ||
@@ -44,0 +45,0 @@ "npm-run-all": "^4.1.5", |
@@ -178,3 +178,3 @@ # loading="lazy" attribute polyfill | ||
See the polyfill in action either by downloading / forking this repo and have a look at `demo/index.html`, or at the hosted demo: <https://mfranzke.github.io/loading-attribute-polyfill/demo/> | ||
See the polyfill in action either by downloading / forking this repository and have a look at `demo/index.html`, or at the hosted demo: <https://mfranzke.github.io/loading-attribute-polyfill/demo/> | ||
@@ -181,0 +181,0 @@ ## Further implementations - Kudos for that |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
108737