123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- let elem = document.createElement('div');
- elem.classList.toggle('test-class', false);
- if (elem.classList.contains('test-class')) {
- let _toggle = DOMTokenList.prototype.toggle;
- DOMTokenList.prototype.toggle = function(token, force) {
- if (arguments.length > 1 && !this.contains(token) === !force) {
- return force;
- } else {
- return _toggle.call(this, token);
- }
- };
- }
- if (!String.prototype.startsWith) {
- String.prototype.startsWith = function(searchString, position){
- position = position || 0;
- return this.substr(position, searchString.length) === searchString;
- };
- }
- if (!String.prototype.endsWith) {
- String.prototype.endsWith = function(searchString, position) {
- var subjectString = this.toString();
- if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
- position = subjectString.length;
- }
- position -= searchString.length;
- var lastIndex = subjectString.indexOf(searchString, position);
- return lastIndex !== -1 && lastIndex === position;
- };
- }
- if (!Array.prototype.find) {
- Object.defineProperty(Array.prototype, "find", {
- value: function(predicate) {
- if (this === null) {
- throw new TypeError('Array.prototype.find called on null or undefined');
- }
- if (typeof predicate !== 'function') {
- throw new TypeError('predicate must be a function');
- }
- var list = Object(this);
- var length = list.length >>> 0;
- var thisArg = arguments[1];
- var value;
- for (var i = 0; i < length; i++) {
- value = list[i];
- if (predicate.call(thisArg, value, i, list)) {
- return value;
- }
- }
- return undefined;
- }
- });
- }
- document.addEventListener("DOMContentLoaded", function() {
- // Disable resizing in Firefox
- document.execCommand("enableObjectResizing", false, false);
- // Disable automatic linkifying in IE11
- document.execCommand("autoUrlDetect", false, false);
- });
|