From 96b22b09689d202e4a3e1a4647374088c9b4faca Mon Sep 17 00:00:00 2001 From: Maximilian Franzke <787658+mfranzke@users.noreply.github.com> Date: Sun, 15 May 2022 20:07:13 +0200 Subject: [PATCH] build: regenerated files for distribution --- dist/loading-attribute-polyfill.js.map | 2 +- dist/loading-attribute-polyfill.modern.js | 2 +- dist/loading-attribute-polyfill.modern.js.map | 2 +- dist/loading-attribute-polyfill.module.js | 2 +- dist/loading-attribute-polyfill.module.js.map | 2 +- dist/loading-attribute-polyfill.umd.js.map | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/loading-attribute-polyfill.js.map b/dist/loading-attribute-polyfill.js.map index 9d54bba1..c349a279 100644 --- a/dist/loading-attribute-polyfill.js.map +++ b/dist/loading-attribute-polyfill.js.map @@ -1 +1 @@ -{"version":3,"file":"loading-attribute-polyfill.js","sources":["../src/loading-attribute-polyfill.js"],"sourcesContent":["/*\n * Loading attribute polyfill - https://github.com/mfranzke/loading-attribute-polyfill\n * @license Copyright(c) 2019 by Maximilian Franzke\n * Credits for the initial kickstarter / script to @Sora2455, and supported by @cbirdsong, @eklingen, @DaPo, @nextgenthemes, @diogoterremoto, @dracos, @Flimm, @TomS-, @vinyfc93, @JordanDysart and @denyshutsal - many thanks for that !\n */\n/*\n * A minimal and dependency-free vanilla JavaScript loading attribute polyfill.\n * Supports standard's functionality and tests for native support upfront.\n * Elsewhere the functionality gets emulated with the support of noscript wrapper tags.\n * Use an IntersectionObserver polyfill in case of IE11 support necessary.\n */\n\nimport './loading-attribute-polyfill.css';\n\nconst config = {\n\tintersectionObserver: {\n\t\t// Start download if the item gets within 256px in the Y axis\n\t\trootMargin: '0px 0px 256px 0px',\n\t\tthreshold: 0.01,\n\t},\n\tlazyImage: 'img[loading=\"lazy\"]',\n\tlazyIframe: 'iframe[loading=\"lazy\"]',\n};\n\n// Device/browser capabilities object\nconst capabilities = {\n\tloading: {\n\t\timage: 'loading' in HTMLImageElement.prototype,\n\t\tiframe: 'loading' in HTMLIFrameElement.prototype,\n\t},\n\tscrolling: 'onscroll' in window,\n};\n\n// Nodelist foreach polyfill / source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach#polyfill\nif (window.NodeList && !NodeList.prototype.forEach) {\n\tNodeList.prototype.forEach = Array.prototype.forEach;\n}\n\n// Define according to browsers support of the IntersectionObserver feature (missing e.g. on IE11 or Safari 11)\nlet intersectionObserver;\n\nif ('IntersectionObserver' in window) {\n\tintersectionObserver = new IntersectionObserver(\n\t\tonIntersection,\n\t\tconfig.intersectionObserver\n\t);\n}\n\n/**\n * Put the source and srcset back where it belongs - now that the elements content is attached to the document, it will load now\n * @param {Object} lazyItem Current item to be restored after lazy loading.\n */\nfunction restoreSource(lazyItem) {\n\tlet srcsetItems = [];\n\n\t// Just in case the img is the decendent of a picture element, check for source tags\n\tif (lazyItem.parentNode.tagName.toLowerCase() === 'picture') {\n\t\tremovePlaceholderSource(lazyItem.parentNode);\n\n\t\tsrcsetItems = Array.prototype.slice.call(\n\t\t\tlazyItem.parentNode.querySelectorAll('source')\n\t\t);\n\t}\n\n\tsrcsetItems.push(lazyItem);\n\n\t// Not using .dataset within those upfollowing lines of code for polyfill independent compatibility down to IE9\n\tsrcsetItems.forEach((item) => {\n\t\tif (item.hasAttribute('data-lazy-srcset')) {\n\t\t\titem.setAttribute('srcset', item.getAttribute('data-lazy-srcset'));\n\t\t\titem.removeAttribute('data-lazy-srcset'); // Not using delete .dataset here for compatibility down to IE9\n\t\t}\n\t});\n\n\tlazyItem.setAttribute('src', lazyItem.getAttribute('data-lazy-src'));\n\tlazyItem.removeAttribute('data-lazy-src'); // Not using delete .dataset here for compatibility down to IE9\n}\n\n/**\n * Remove the source tag preventing the loading of picture assets\n * @param {Object} lazyItemPicture Current item to be restored after lazy loading.\n */\nfunction removePlaceholderSource(lazyItemPicture) {\n\tconst placeholderSource = lazyItemPicture.querySelector(\n\t\t'source[data-lazy-remove]'\n\t);\n\n\tif (placeholderSource) {\n\t\t// Preferred .removeChild over .remove here for IE\n\t\tlazyItemPicture.removeChild(placeholderSource);\n\t}\n}\n\n/**\n * Handle IntersectionObservers callback\n * @param {Object} entries Target elements Intersection observed changes\n * @param {Object} observer IntersectionObserver instance reference\n */\nfunction onIntersection(entries, observer) {\n\tentries.forEach((entry) => {\n\t\t// Mitigation for EDGE lacking support of .isIntersecting until v15, compare to e.g. https://github.com/w3c/IntersectionObserver/issues/211#issuecomment-309144669\n\t\tif (entry.intersectionRatio === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\t// If the item is visible now, load it and stop watching it\n\t\tconst lazyItem = entry.target;\n\n\t\tobserver.unobserve(lazyItem);\n\n\t\trestoreSource(lazyItem);\n\t});\n}\n\n/**\n * Handle printing the page\n */\nfunction onPrinting() {\n\tif (typeof window.matchMedia === 'undefined') {\n\t\treturn;\n\t}\n\n\tconst mediaQueryList = window.matchMedia('print');\n\n\tmediaQueryList.addListener((mql) => {\n\t\tif (mql.matches) {\n\t\t\tdocument\n\t\t\t\t.querySelectorAll(\n\t\t\t\t\tconfig.lazyImage +\n\t\t\t\t\t\t'[data-lazy-src],' +\n\t\t\t\t\t\tconfig.lazyIframe +\n\t\t\t\t\t\t'[data-lazy-src]'\n\t\t\t\t)\n\t\t\t\t.forEach((lazyItem) => {\n\t\t\t\t\trestoreSource(lazyItem);\n\t\t\t\t});\n\t\t}\n\t});\n}\n\n/**\n * Get and prepare the HTML code depending on feature detection for both image as well as iframe,\n * and if not scrolling supported, because it's a Google or Bing Bot\n * @param {String} lazyAreaHtml Noscript inner HTML code that src-urls need to get rewritten\n */\nfunction getAndPrepareHTMLCode(noScriptTag) {\n\t// The contents of a