1 | let elem = document.createElement('div');
|
2 | elem.classList.toggle('test-class', false);
|
3 | if (elem.classList.contains('test-class')) {
|
4 | let _toggle = DOMTokenList.prototype.toggle;
|
5 | DOMTokenList.prototype.toggle = function(token, force) {
|
6 | if (arguments.length > 1 && !this.contains(token) === !force) {
|
7 | return force;
|
8 | } else {
|
9 | return _toggle.call(this, token);
|
10 | }
|
11 | };
|
12 | }
|
13 |
|
14 | if (!String.prototype.startsWith) {
|
15 | String.prototype.startsWith = function(searchString, position){
|
16 | position = position || 0;
|
17 | return this.substr(position, searchString.length) === searchString;
|
18 | };
|
19 | }
|
20 |
|
21 | if (!String.prototype.endsWith) {
|
22 | String.prototype.endsWith = function(searchString, position) {
|
23 | var subjectString = this.toString();
|
24 | if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
|
25 | position = subjectString.length;
|
26 | }
|
27 | position -= searchString.length;
|
28 | var lastIndex = subjectString.indexOf(searchString, position);
|
29 | return lastIndex !== -1 && lastIndex === position;
|
30 | };
|
31 | }
|
32 |
|
33 | if (!Array.prototype.find) {
|
34 | Object.defineProperty(Array.prototype, "find", {
|
35 | value: function(predicate) {
|
36 | if (this === null) {
|
37 | throw new TypeError('Array.prototype.find called on null or undefined');
|
38 | }
|
39 | if (typeof predicate !== 'function') {
|
40 | throw new TypeError('predicate must be a function');
|
41 | }
|
42 | var list = Object(this);
|
43 | var length = list.length >>> 0;
|
44 | var thisArg = arguments[1];
|
45 | var value;
|
46 |
|
47 | for (var i = 0; i < length; i++) {
|
48 | value = list[i];
|
49 | if (predicate.call(thisArg, value, i, list)) {
|
50 | return value;
|
51 | }
|
52 | }
|
53 | return undefined;
|
54 | }
|
55 | });
|
56 | }
|
57 |
|
58 | document.addEventListener("DOMContentLoaded", function() {
|
59 |
|
60 | document.execCommand("enableObjectResizing", false, false);
|
61 |
|
62 | document.execCommand("autoUrlDetect", false, false);
|
63 | });
|