PageSourceSearch

https://ahdb.org.uk/Themes/ProjectBlue/Content/mmenu-js-master/dist/mmenu.polyfills.js

js ahdb.org.uk collected 2026-09-24 18:09:51 UTC 5,365 bytes, 150 lines download raw bytes

vendor: 4,689 bytes, lines 1-132
1// Source: https://developer.mozilla.org/en-US/docs/Web/API/NodeList/forEach
2if (window.NodeList && !NodeList.prototype.forEach) {
3    NodeList.prototype.forEach = function(callback, thisArg) {
4        thisArg = thisArg || window;
5        for (var i = 0; i < this.length; i++) {
6            callback.call(thisArg, this[i], i, this);
7        }
8    };
9}
10
11// Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/matches
12if (!Element.prototype.matches) {
13    Element.prototype.matches =
14        Element.prototype.matchesSelector ||
15        Element.prototype.mozMatchesSelector ||
16        Element.prototype.msMatchesSelector ||
17        Element.prototype.oMatchesSelector ||
18        Element.prototype.webkitMatchesSelector ||
19        function(s) {
20            var matches = (
21                    this.document || this.ownerDocument
22                ).querySelectorAll(s),
23                i = matches.length;
24            while (--i >= 0 && matches.item(i) !== this) {}
25            return i > -1;
26        };
27}
28
29// Source: https://developer.mozilla.org/en-US/docs/Web/API/Element/closest
30if (!Element.prototype.matches) {
31    Element.prototype.matches =
32        Element.prototype.msMatchesSelector ||
33        Element.prototype.webkitMatchesSelector;
34}
35
36if (!Element.prototype.closest) {
37    Element.prototype.closest = function(s) {
38        var el = this;
39
40        do {
41            if (el.matches(s)) return el;
42            el = el.parentElement || el.parentNode;
43        } while (el !== null && el.nodeType === 1);
44        return null;
45    };
46}
47
48// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/prepend()/prepend().md
49(function(arr) {
50    arr.forEach(function(item) {
51        if (item.hasOwnProperty('prepend')) {
52            return;
53        }
54        Object.defineProperty(item, 'prepend', {
55            configurable: true,
56            enumerable: true,
57            writable: true,
58            value: function prepend() {
59                var argArr = Array.prototype.slice.call(arguments),
60                    docFrag = document.createDocumentFragment();
61
62                argArr.forEach(function(argItem) {
63                    var isNode = argItem instanceof Node;
64                    docFrag.appendChild(
65                        isNode
66                            ? argItem
67                            : document.createTextNode(String(argItem))
68                    );
69                });
70
71                this.insertBefore(docFrag, this.firstChild);
72            }
73        });
74    });
75})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
76
77// Source: https://github.com/jserz/js_piece/blob/master/DOM/ParentNode/append()/append().md
78(function(arr) {
79    arr.forEach(function(item) {
80        if (item.hasOwnProperty('append')) {
81            return;
82        }
83        Object.defineProperty(item, 'append', {
84            configurable: true,
85            enumerable: true,
86            writable: true,
87            value: function append() {
88                var argArr = Array.prototype.slice.call(arguments),
89                    docFrag = document.createDocumentFragment();
90
91                argArr.forEach(function(argItem) {
92                    var isNode = argItem instanceof Node;
93                    docFrag.appendChild(
94                        isNode
95                            ? argItem
96                            : document.createTextNode(String(argItem))
97                    );
98                });
99
100                this.appendChild(docFrag);
101            }
102        });
103    });
104})([Element.prototype, Document.prototype, DocumentFragment.prototype]);
105
106// Source: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/before()/before().md
107(function(arr) {
108    arr.forEach(function(item) {
109        if (item.hasOwnProperty('before')) {
110            return;
111        }
112        Object.defineProperty(item, 'before', {
113            configurable: true,
114            enumerable: true,
115            writable: true,
116            value: function before() {
117                var argArr = Array.prototype.slice.call(arguments),
118                    docFrag = document.createDocumentFragment();
119
120                argArr.forEach(function(argItem) {
121                    var isNode = argItem instanceof Node;
122                    docFrag.appendChild(
123                        isNode
124                            ? argItem
125                            : document.createTextNode(String(argItem))
126                    );
127                });
128
129                this.parentNode.insertBefore(docFrag, this);
130            }
131        });
132    });
133})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);
134
135// Source: https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md
136(function(arr) {
137    arr.forEach(function(item) {
138        if (item.hasOwnProperty('remove')) {
139            return;
140        }
141        Object.defineProperty(item, 'remove', {
142            configurable: true,
143            enumerable: true,
144            writable: true,
145            value: function remove() {
146                if (this.parentNode !== null) this.parentNode.removeChild(this);
147            }
148        });
149    });
150})([Element.prototype, CharacterData.prototype, DocumentType.prototype]);

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.