PageSourceSearch

https://estream.help/assets-new/js/svg4everybody.js

js estream.help collected 2026-10-02 01:54:39 UTC 6,307 bytes, 113 lines download raw bytes

1/*
2https://github.com/jonathantneal/svg4everybody
3Creative Commons license  v1
4https://creativecommons.org/publicdomain/zero/1.0/
5
6*/
7
8!function (root, factory) {
9    "function" == typeof define && define.amd ? // AMD. Register as an anonymous module unless amdModuleId is set
10    define([], function() {
11        return root.svg4everybody = factory();
12    }) : "object" == typeof module && module.exports ? // Node. Does not work with strict CommonJS, but
13    // only CommonJS-like environments that support module.exports,
14    // like Node.
15    module.exports = factory() : root.svg4everybody = factory();
16}(this, function() {
17    /*! svg4everybody v2.1.9 | github.com/jonathantneal/svg4everybody */
18    function embed(parent, svg, target) {
19        // if the target exists
20        if (target) {
21            // create a document fragment to hold the contents of the target
22            var fragment = document.createDocumentFragment(), viewBox = !svg.hasAttribute("viewBox") && target.getAttribute("viewBox");
23            // conditionally set the viewBox on the svg
vendor: 5,240 bytes, lines 24-113
24            viewBox && svg.setAttribute("viewBox", viewBox);
25            // copy the contents of the clone into the fragment
26            for (// clone the target
27            var clone = target.cloneNode(!0); clone.childNodes.length; ) {
28                fragment.appendChild(clone.firstChild);
29            }
30            // append the fragment into the svg
31            parent.appendChild(fragment);
32        }
33    }
34    function loadreadystatechange(xhr) {
35        // listen to changes in the request
36        xhr.onreadystatechange = function() {
37            // if the request is ready
38            if (4 === xhr.readyState) {
39                // get the cached html document
40                var cachedDocument = xhr._cachedDocument;
41                // ensure the cached html document based on the xhr response
42                cachedDocument || (cachedDocument = xhr._cachedDocument = document.implementation.createHTMLDocument(""),
43                cachedDocument.body.innerHTML = xhr.responseText, xhr._cachedTarget = {}), // clear the xhr embeds list and embed each item
44                xhr._embeds.splice(0).map(function(item) {
45                    // get the cached target
46                    var target = xhr._cachedTarget[item.id];
47                    // ensure the cached target
48                    target || (target = xhr._cachedTarget[item.id] = cachedDocument.getElementById(item.id)),
49                    // embed the target into the svg
50                    embed(item.parent, item.svg, target);
51                });
52            }
53        }, // test the ready state change immediately
54        xhr.onreadystatechange();
55    }
56    function svg4everybody(rawopts) {
57        function oninterval() {
58            // while the index exists in the live <use> collection
59            for (// get the cached <use> index
60            var index = 0; index < uses.length; ) {
61                // get the current <use>
62                var use = uses[index], parent = use.parentNode, svg = getSVGAncestor(parent), src = use.getAttribute("xlink:href") || use.getAttribute("href");
63                if (!src && opts.attributeName && (src = use.getAttribute(opts.attributeName)),
64                svg && src) {
65                    if (polyfill) {
66                        if (!opts.validate || opts.validate(src, svg, use)) {
67                            // remove the <use> element
68                            parent.removeChild(use);
69                            // parse the src and get the url and id
70                            var srcSplit = src.split("#"), url = srcSplit.shift(), id = srcSplit.join("#");
71                            // if the link is external
72                            if (url.length) {
73                                // get the cached xhr request
74                                var xhr = requests[url];
75                                // ensure the xhr request exists
76                                xhr || (xhr = requests[url] = new XMLHttpRequest(), xhr.open("GET", url), xhr.send(),
77                                xhr._embeds = []), // add the svg and id as an item to the xhr embeds list
78                                xhr._embeds.push({
79                                    parent: parent,
80                                    svg: svg,
81                                    id: id
82                                }), // prepare the xhr ready state change event
83                                loadreadystatechange(xhr);
84                            } else {
85                                // embed the local id into the svg
86                                embed(parent, svg, document.getElementById(id));
87                            }
88                        } else {
89                            // increase the index when the previous value was not "valid"
90                            ++index, ++numberOfSvgUseElementsToBypass;
91                        }
92                    }
93                } else {
94                    // increase the index when the previous value was not "valid"
95                    ++index;
96                }
97            }
98            // continue the interval
99            (!uses.length || uses.length - numberOfSvgUseElementsToBypass > 0) && requestAnimationFrame(oninterval, 67);
100        }
101        var polyfill, opts = Object(rawopts), newerIEUA = /\bTrident\/[567]\b|\bMSIE (?:9|10)\.0\b/, webkitUA = /\bAppleWebKit\/(\d+)\b/, olderEdgeUA = /\bEdge\/12\.(\d+)\b/, edgeUA = /\bEdge\/.(\d+)\b/, inIframe = window.top !== window.self;
102        polyfill = "polyfill" in opts ? opts.polyfill : newerIEUA.test(navigator.userAgent) || (navigator.userAgent.match(olderEdgeUA) || [])[1] < 10547 || (navigator.userAgent.match(webkitUA) || [])[1] < 537 || edgeUA.test(navigator.userAgent) && inIframe;
103        // create xhr requests object
104        var requests = {}, requestAnimationFrame = window.requestAnimationFrame || setTimeout, uses = document.getElementsByTagName("use"), numberOfSvgUseElementsToBypass = 0;
105        // conditionally start the interval if the polyfill is active
106        polyfill && oninterval();
107    }
108    function getSVGAncestor(node) {
109        for (var svg = node; "svg" !== svg.nodeName.toLowerCase() && (svg = svg.parentNode); ) {}
110        return svg;
111    }
112    return svg4everybody;
113});

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.