PageSourceSearch

https://www.swlauriersb.qc.ca/wp-content/themes/reptile/static/js/libs/polyfill-ie11.js

js swlauriersb.qc.ca collected 2026-10-02 08:11:42 UTC 10,846 bytes, 360 lines download raw bytes

1if ('NodeList' in window && !NodeList.prototype.forEach) {
2	console.info('polyfill for IE11');
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// Create Element.remove() function if not exist
12if (!('remove' in Element.prototype)) {
13    Element.prototype.remove = function() {
14        if (this.parentNode) {
15            this.parentNode.removeChild(this);
16        }
17    };
18}
19
20/**
21 *
22 *
23 * @author Jerry Bendy <[email protected]>
24 * @licence MIT
25 *
26 */
27
28(function(self) {
29    'use strict';
30
31    var nativeURLSearchParams = (self.URLSearchParams && self.URLSearchParams.prototype.get) ? self.URLSearchParams : null,
32        isSupportObjectConstructor = nativeURLSearchParams && (new nativeURLSearchParams({a: 1})).toString() === 'a=1',
33        // There is a bug in safari 10.1 (and earlier) that incorrectly decodes `%2B` as an empty space and not a plus.
34        decodesPlusesCorrectly = nativeURLSearchParams && (new nativeURLSearchParams('s=%2B').get('s') === '+'),
35        __URLSearchParams__ = "__URLSearchParams__",
36        // Fix bug in Edge which cannot encode ' &' correctly
37        encodesAmpersandsCorrectly = nativeURLSearchParams ? (function() {
38            var ampersandTest = new nativeURLSearchParams();
39            ampersandTest.append('s', ' &');
40            return ampersandTest.toString() === 's=+%26';
41        })() : true,
42        prototype = URLSearchParamsPolyfill.prototype,
43        iterable = !!(self.Symbol && self.Symbol.iterator);
44
45    if (nativeURLSearchParams && isSupportObjectConstructor && decodesPlusesCorrectly && encodesAmpersandsCorrectly) {
46        return;
47    }
48
49
50    /**
51     * Make a URLSearchParams instance
52     *
53     * @param {object|string|URLSearchParams} search
54     * @constructor
55     */
56    function URLSearchParamsPolyfill(search) {
57        search = search || "";
58
59        // support construct object with another URLSearchParams instance
60        if (search instanceof URLSearchParams || search instanceof URLSearchParamsPolyfill) {
61            search = search.toString();
62        }
63        this [__URLSearchParams__] = parseToDict(search);
64    }
65
66
67    /**
68     * Appends a specified key/value pair as a new search parameter.
69     *
70     * @param {string} name
71     * @param {string} value
72     */
73    prototype.append = function(name, value) {
74        appendTo(this [__URLSearchParams__], name, value);
75    };
76
77    /**
78     * Deletes the given search parameter, and its associated value,
79     * from the list of all search parameters.
80     *
81     * @param {string} name
82     */
83    prototype['delete'] = function(name) {
84        delete this [__URLSearchParams__] [name];
85    };
86
87    /**
88     * Returns the first value associated to the given search parameter.
89     *
90     * @param {string} name
91     * @returns {string|null}
92     */
93    prototype.get = function(name) {
94        var dict = this [__URLSearchParams__];
95        return this.has(name) ? dict[name][0] : null;
96    };
97
98    /**
99     * Returns all the values association with a given search parameter.
100     *
101     * @param {string} name
102     * @returns {Array}
103     */
104    prototype.getAll = function(name) {
105        var dict = this [__URLSearchParams__];
106        return this.has(name) ? dict [name].slice(0) : [];
107    };
108
109    /**
110     * Returns a Boolean indicating if such a search parameter exists.
111     *
112     * @param {string} name
113     * @returns {boolean}
114     */
115    prototype.has = function(name) {
116        return hasOwnProperty(this [__URLSearchParams__], name);
117    };
118
119    /**
120     * Sets the value associated to a given search parameter to
121     * the given value. If there were several values, delete the
122     * others.
123     *
124     * @param {string} name
125     * @param {string} value
126     */
127    prototype.set = function set(name, value) {
128        this [__URLSearchParams__][name] = ['' + value];
129    };
130
131    /**
132     * Returns a string containg a query string suitable for use in a URL.
133     *
134     * @returns {string}
135     */
136    prototype.toString = function() {
137        var dict = this[__URLSearchParams__], query = [], i, key, name, value;
138        for (key in dict) {
139            name = encode(key);
140            for (i = 0, value = dict[key]; i < value.length; i++) {
141                query.push(name + '=' + encode(value[i]));
142            }
143        }
144        return query.join('&');
145    };
146
147    // There is a bug in Safari 10.1 and `Proxy`ing it is not enough.
148    var forSureUsePolyfill = !decodesPlusesCorrectly;
149    var useProxy = (!forSureUsePolyfill && nativeURLSearchParams && !isSupportObjectConstructor && self.Proxy);
150    /*
151     * Apply polifill to global object and append other prototype into it
152     */
153    Object.defineProperty(self, 'URLSearchParams', {
154        value: (useProxy ?
155            // Safari 10.0 doesn't support Proxy, so it won't extend URLSearchParams on safari 10.0
156            new Proxy(nativeURLSearchParams, {
157                construct: function(target, args) {
158                    return new target((new URLSearchParamsPolyfill(args[0]).toString()));
159                }
160            }) :
161            URLSearchParamsPolyfill)
162    });
163
164    var USPProto = self.URLSearchParams.prototype;
165
166    USPProto.polyfill = true;
167
168    /**
169     *
170     * @param {function} callback
171     * @param {object} thisArg
172     */
173    USPProto.forEach = USPProto.forEach || function(callback, thisArg) {
174        var dict = parseToDict(this.toString());
175        Object.getOwnPropertyNames(dict).forEach(function(name) {
176            dict[name].forEach(function(value) {
177                callback.call(thisArg, value, name, this);
178            }, this);
179        }, this);
180    };
181
182    /**
183     * Sort all name-value pairs
184     */
185    USPProto.sort = USPProto.sort || function() {
186        var dict = parseToDict(this.toString()), keys = [], k, i, j;
187        for (k in dict) {
188            keys.push(k);
189        }
190        keys.sort();
191
192        for (i = 0; i < keys.length; i++) {
193            this['delete'](keys[i]);
194        }
195        for (i = 0; i < keys.length; i++) {
196            var key = keys[i], values = dict[key];
197            for (j = 0; j < values.length; j++) {
198                this.append(key, values[j]);
199            }
200        }
201    };
202
203    /**
204     * Returns an iterator allowing to go through all keys of
205     * the key/value pairs contained in this object.
206     *
207     * @returns {function}
208     */
209    USPProto.keys = USPProto.keys || function() {
210        var items = [];
211        this.forEach(function(item, name) {
212            items.push(name);
213        });
214        return makeIterator(items);
215    };
216
217    /**
218     * Returns an iterator allowing to go through all values of
219     * the key/value pairs contained in this object.
220     *
221     * @returns {function}
222     */
223    USPProto.values = USPProto.values || function() {
224        var items = [];
225        this.forEach(function(item) {
226            items.push(item);
227        });
228        return makeIterator(items);
229    };
230
231    /**
232     * Returns an iterator allowing to go through all key/value
233     * pairs contained in this object.
234     *
235     * @returns {function}
236     */
237    USPProto.entries = USPProto.entries || function() {
238        var items = [];
239        this.forEach(function(item, name) {
240            items.push([name, item]);
241        });
242        return makeIterator(items);
243    };
244
245
246    if (iterable) {
vendor: 3,396 bytes, lines 247-360
247        USPProto[self.Symbol.iterator] = USPProto[self.Symbol.iterator] || USPProto.entries;
248    }
249
250
251    function encode(str) {
252        var replace = {
253            '!': '%21',
254            "'": '%27',
255            '(': '%28',
256            ')': '%29',
257            '~': '%7E',
258            '%20': '+',
259            '%00': '\x00'
260        };
261        return encodeURIComponent(str).replace(/[!'\(\)~]|%20|%00/g, function(match) {
262            return replace[match];
263        });
264    }
265
266    function decode(str) {
267        return str
268            .replace(/[ +]/g, '%20')
269            .replace(/(%[a-f0-9]{2})+/ig, function(match) {
270                return decodeURIComponent(match);
271            });
272    }
273
274    function makeIterator(arr) {
275        var iterator = {
276            next: function() {
277                var value = arr.shift();
278                return {done: value === undefined, value: value};
279            }
280        };
281
282        if (iterable) {
283            iterator[self.Symbol.iterator] = function() {
284                return iterator;
285            };
286        }
287
288        return iterator;
289    }
290
291    function parseToDict(search) {
292        var dict = {};
293
294        if (typeof search === "object") {
295            // if `search` is an array, treat it as a sequence
296            if (isArray(search)) {
297                for (var i = 0; i < search.length; i++) {
298                    var item = search[i];
299                    if (isArray(item) && item.length === 2) {
300                        appendTo(dict, item[0], item[1]);
301                    } else {
302                        throw new TypeError("Failed to construct 'URLSearchParams': Sequence initializer must only contain pair elements");
303                    }
304                }
305
306            } else {
307                for (var key in search) {
308                    if (search.hasOwnProperty(key)) {
309                        appendTo(dict, key, search[key]);
310                    }
311                }
312            }
313
314        } else {
315            // remove first '?'
316            if (search.indexOf("?") === 0) {
317                search = search.slice(1);
318            }
319
320            var pairs = search.split("&");
321            for (var j = 0; j < pairs.length; j++) {
322                var value = pairs [j],
323                    index = value.indexOf('=');
324
325                if (-1 < index) {
326                    appendTo(dict, decode(value.slice(0, index)), decode(value.slice(index + 1)));
327
328                } else {
329                    if (value) {
330                        appendTo(dict, decode(value), '');
331                    }
332                }
333            }
334        }
335
336        return dict;
337    }
338
339    function appendTo(dict, name, value) {
340        var val = typeof value === 'string' ? value : (
341            value !== null && value !== undefined && typeof value.toString === 'function' ? value.toString() : JSON.stringify(value)
342        );
343
344        // #47 Prevent using `hasOwnProperty` as a property name
345        if (hasOwnProperty(dict, name)) {
346            dict[name].push(val);
347        } else {
348            dict[name] = [val];
349        }
350    }
351
352    function isArray(val) {
353        return !!val && '[object Array]' === Object.prototype.toString.call(val);
354    }
355
356    function hasOwnProperty(obj, prop) {
357        return Object.prototype.hasOwnProperty.call(obj, prop);
358    }
359
360})(typeof global !== 'undefined' ? global : (typeof window !== 'undefined' ? window : this));

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.