1function loadSvg(el) { 2 if (typeof SVGRect === undefined && !el) return; 3 var ajax = new XMLHttpRequest(); 4 ajax.open("GET", el.src, true); 5 ajax.send(); 6 7 /*Append the SVG to the el*/ 8 9 ajax.onload = function (e) { 10 let svgContainer = document.createElement('span'); 11 svgContainer.className = el.className; 12 svgContainer.className += ' svg-inlined'; 13 svgContainer.innerHTML = ajax.responseText; 14 el.parentNode.insertBefore(svgContainer, el); 15 el.remove(); 16 }; 17} 18function fetchSvgInline(image) { 19 fetch(image.src).then(response => response.text()).then(response => { 20 const svgStr = response; 21 if (svgStr.indexOf('<svg') === -1) { 22 return; 23 } 24 const span = document.createElement('span'); 25 span.className = image.className + ' svg-inlined'; 26 span.innerHTML = svgStr; 27 const inlineSvg = span.querySelector('svg'); 28 inlineSvg.setAttribute('aria-label', image.alt || ''); 29 // inlineSvg.setAttribute('class', image.className); // IE doesn't support classList on SVGs 30 inlineSvg.setAttribute('focusable', false); 31 inlineSvg.setAttribute('role', 'img'); 32 if (image.height) { 33 inlineSvg.setAttribute('height', image.height); 34 } 35 if (image.width) { 36 inlineSvg.setAttribute('width', image.width); 37 } 38 image.parentNode.replaceChild(span, image); 39 }).catch(() => { 40 image.classList.add('not-inline'); 41 console.log('image not found'); 42 }); 43} 44; 45document.addEventListener("DOMContentLoaded", e => { 46 for (el of document.querySelectorAll('img.custom-logo[src*=".svg"], img.to-inline')) { 47 fetchSvgInline(el); 48 } 49});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.