polyfill.js 4.92 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
1
2
3
4
5
6
/*!
  * Bootstrap polyfill.js v4.3.1 (https://getbootstrap.com/)
  * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
(function (global, factory) {
Mark Otto's avatar
dist v5    
Mark Otto committed
7
8
9
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
  (global = global || self, factory(global.Polyfill = {}));
XhmikosR's avatar
XhmikosR committed
10
}(this, (function (exports) { 'use strict';
XhmikosR's avatar
XhmikosR committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

  /**
   * --------------------------------------------------------------------------
   * Bootstrap (v4.3.1): util/index.js
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
      prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
    } while (document.getElementById(prefix));

    return prefix;
  };

Mark Otto's avatar
dist v5    
Mark Otto committed
34
35
36
37
38
39
  /* istanbul ignore file */
  var _Element$prototype = Element.prototype;
      exports.matches = _Element$prototype.matches;
      exports.closest = _Element$prototype.closest;
  exports.find = Element.prototype.querySelectorAll;
  exports.findOne = Element.prototype.querySelector;
XhmikosR's avatar
XhmikosR committed
40

Mark Otto's avatar
dist v5    
Mark Otto committed
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  exports.createCustomEvent = function createCustomEvent(eventName, params) {
    var cEvent = new CustomEvent(eventName, params);
    return cEvent;
  };

  if (typeof window.CustomEvent !== 'function') {
    exports.createCustomEvent = function createCustomEvent(eventName, params) {
      params = params || {
        bubbles: false,
        cancelable: false,
        detail: null
      };
      var evt = document.createEvent('CustomEvent');
      evt.initCustomEvent(eventName, params.bubbles, params.cancelable, params.detail);
      return evt;
    };
  }
XhmikosR's avatar
XhmikosR committed
58

Mark Otto's avatar
dist v5    
Mark Otto committed
59
60
61
62
63
64
  var workingDefaultPrevented = function () {
    var e = document.createEvent('CustomEvent');
    e.initEvent('Bootstrap', true, true);
    e.preventDefault();
    return e.defaultPrevented;
  }();
XhmikosR's avatar
XhmikosR committed
65

Mark Otto's avatar
dist v5    
Mark Otto committed
66
67
  if (!workingDefaultPrevented) {
    var origPreventDefault = Event.prototype.preventDefault;
XhmikosR's avatar
XhmikosR committed
68

Mark Otto's avatar
dist v5    
Mark Otto committed
69
70
71
    Event.prototype.preventDefault = function () {
      if (!this.cancelable) {
        return;
XhmikosR's avatar
XhmikosR committed
72
73
      }

Mark Otto's avatar
dist v5    
Mark Otto committed
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
      origPreventDefault.call(this);
      Object.defineProperty(this, 'defaultPrevented', {
        get: function get() {
          return true;
        },
        configurable: true
      });
    };
  } // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached


  var defaultPreventedPreservedOnDispatch = function () {
    var e = exports.createCustomEvent('Bootstrap', {
      cancelable: true
    });
    var element = document.createElement('div');
    element.addEventListener('Bootstrap', function () {
      return null;
    });
    e.preventDefault();
    element.dispatchEvent(e);
    return e.defaultPrevented;
  }();
XhmikosR's avatar
XhmikosR committed
97

Mark Otto's avatar
dist v5    
Mark Otto committed
98
99
100
  if (!exports.matches) {
    exports.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
  }
XhmikosR's avatar
XhmikosR committed
101

Mark Otto's avatar
dist v5    
Mark Otto committed
102
103
104
  if (!exports.closest) {
    exports.closest = function closest(selector) {
      var element = this;
XhmikosR's avatar
XhmikosR committed
105

Mark Otto's avatar
dist v5    
Mark Otto committed
106
107
108
      do {
        if (exports.matches.call(element, selector)) {
          return element;
XhmikosR's avatar
XhmikosR committed
109
110
        }

Mark Otto's avatar
dist v5    
Mark Otto committed
111
112
        element = element.parentElement || element.parentNode;
      } while (element !== null && element.nodeType === 1);
XhmikosR's avatar
XhmikosR committed
113

Mark Otto's avatar
dist v5    
Mark Otto committed
114
115
116
      return null;
    };
  }
XhmikosR's avatar
XhmikosR committed
117

Mark Otto's avatar
dist v5    
Mark Otto committed
118
  var scopeSelectorRegex = /:scope\b/;
XhmikosR's avatar
XhmikosR committed
119

Mark Otto's avatar
dist v5    
Mark Otto committed
120
121
  var supportScopeQuery = function () {
    var element = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
122

Mark Otto's avatar
dist v5    
Mark Otto committed
123
124
    try {
      element.querySelectorAll(':scope *');
XhmikosR's avatar
XhmikosR committed
125
    } catch (_) {
Mark Otto's avatar
dist v5    
Mark Otto committed
126
127
128
129
130
131
132
133
134
135
136
137
138
      return false;
    }

    return true;
  }();

  if (!supportScopeQuery) {
    exports.find = function find(selector) {
      if (!scopeSelectorRegex.test(selector)) {
        return this.querySelectorAll(selector);
      }

      var hasId = Boolean(this.id);
XhmikosR's avatar
XhmikosR committed
139

Mark Otto's avatar
dist v5    
Mark Otto committed
140
141
142
143
144
145
146
147
148
149
150
151
      if (!hasId) {
        this.id = getUID('scope');
      }

      var nodeList = null;

      try {
        selector = selector.replace(scopeSelectorRegex, "#" + this.id);
        nodeList = this.querySelectorAll(selector);
      } finally {
        if (!hasId) {
          this.removeAttribute('id');
XhmikosR's avatar
XhmikosR committed
152
        }
Mark Otto's avatar
dist v5    
Mark Otto committed
153
      }
XhmikosR's avatar
XhmikosR committed
154

Mark Otto's avatar
dist v5    
Mark Otto committed
155
156
157
158
159
160
161
      return nodeList;
    };

    exports.findOne = function findOne(selector) {
      if (!scopeSelectorRegex.test(selector)) {
        return this.querySelector(selector);
      }
XhmikosR's avatar
XhmikosR committed
162

Mark Otto's avatar
dist v5    
Mark Otto committed
163
164
165
166
167
168
169
      var matches = exports.find.call(this, selector);

      if (typeof matches[0] !== 'undefined') {
        return matches[0];
      }

      return null;
XhmikosR's avatar
XhmikosR committed
170
    };
Mark Otto's avatar
dist v5    
Mark Otto committed
171
172
173
  }

  exports.defaultPreventedPreservedOnDispatch = defaultPreventedPreservedOnDispatch;
XhmikosR's avatar
XhmikosR committed
174

Mark Otto's avatar
dist v5    
Mark Otto committed
175
  Object.defineProperty(exports, '__esModule', { value: true });
XhmikosR's avatar
XhmikosR committed
176

XhmikosR's avatar
XhmikosR committed
177
})));
XhmikosR's avatar
XhmikosR committed
178
//# sourceMappingURL=polyfill.js.map