wp_back/wp-content/plugins/svg-support/js/min/svgs-inline-vanilla-min.js
2024-05-20 15:37:46 +03:00

1 line
1.8 KiB
JavaScript

document.addEventListener("DOMContentLoaded",(function(e){function t(e){if("IMG"===e.nodeName){var t=e.id,n=e.classList,i=e.src;if(i.endsWith("svg")){var r=new XMLHttpRequest;r.onreadystatechange=function(){if(4==r.readyState&&200==r.status){let o;data=r.responseText;const d=undefined;var i,a=(i=(new DOMParser).parseFromString(data,"text/html").getElementsByTagName("svg")[0]).id;if(void 0===t?void 0===a?(t="svg-replaced-"+s,i.setAttribute("id",t)):t=a:i.setAttribute("id",t),void 0!==n&&i.setAttribute("class",n+" replaced-svg svg-replaced-"+s),i.removeAttribute("xmlns:a"),"on"==frontSanitizationEnabled&&""!=i.outerHTML){var i=DOMPurify.sanitize(i.outerHTML);e.outerHTML=i}else e.replaceWith(i);s++}},r.open("GET",i,!1),r.send(null)}}}function n(e){if(e.childNodes.length>0)for(var s=0;s<e.childNodes.length;s++){var i;if("IMG"==e.childNodes[s].nodeName)t(e.childNodes[s]);else n(e.childNodes[s])}}let s=0;(bodhisvgsInlineSupport=function(){if("true"===ForceInlineSVGActive)for(var e=document.getElementsByTagName("img"),s=0;s<e.length;s++)void 0!==e[s].src&&e[s].src.match(/\.(svg)/)&&(e[s].classList.contains(cssTarget.ForceInlineSVG)||e[s].classList.add(cssTarget.ForceInlineSVG));if(String.prototype.endsWith||(String.prototype.endsWith=function(e,t){var n=this.toString();("number"!=typeof t||!isFinite(t)||Math.floor(t)!==t||t>n.length)&&(t=n.length),t-=e.length;var s=n.lastIndexOf(e,t);return-1!==s&&s===t}),String.prototype.endsWith=function(e){var t=this.length-e.length;return t>=0&&this.lastIndexOf(e)===t},"true"===ForceInlineSVGActive)var i="img."!==cssTarget.Bodhi?cssTarget.ForceInlineSVG:"style-svg";else var i="img."!==cssTarget?cssTarget:"style-svg";i=i.replace("img.","");for(var e=document.getElementsByClassName(i),s=0;s<e.length;s++){var r;if(void 0===e[s].src)n(e[s]);else t(e[s])}})()}));