PageSourceSearch

https://www.lomado.de/templates/Snackys/js/snackys/classList.js

js lomado.de collected 2026-10-04 16:54:01 UTC 1,655 bytes, 54 lines download raw bytes

1/* classlist polyfill */
2/*
3 * Minimal classList shim for IE 9
4 * By Devon Govett
5 * MIT LICENSE
6 */
7
8
9if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
10    Object.defineProperty(HTMLElement.prototype, 'classList', {
11        get: function() {
12            var self = this;
13            function update(fn) {
14                return function(value) {
15                    var classes = self.className.split(/\s+/),
16                        index = classes.indexOf(value);
17
18                    fn(classes, index, value);
19                    self.className = classes.join(" ");
20                }
21            }
22
23            var ret = {                    
24                add: update(function(classes, index, value) {
25                    ~index || classes.push(value);
26                }),
27
28                remove: update(function(classes, index) {
29                    ~index && classes.splice(index, 1);
30                }),
31
32                toggle: update(function(classes, index, value) {
33                    ~index ? classes.splice(index, 1) : classes.push(value);
34                }),
35
36                contains: function(value) {
37                    return !!~self.className.split(/\s+/).indexOf(value);
38                },
39
40                item: function(i) {
41                    return self.className.split(/\s+/)[i] || null;
42                }
43            };
44            
45            Object.defineProperty(ret, 'length', {
46                get: function() {
47                    return self.className.split(/\s+/).length;
48                }
49            });
50
51            return ret;
52        }
53    });
54}

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.