polyfill.js 3.15 KB
Newer Older
XhmikosR's avatar
XhmikosR committed
1
/*!
XhmikosR's avatar
XhmikosR committed
2
  * Bootstrap polyfill.js v5.0.0-alpha2 (https://getbootstrap.com/)
XhmikosR's avatar
XhmikosR committed
3
  * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
XhmikosR's avatar
XhmikosR committed
4
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
XhmikosR committed
5
6
  */
(function (global, factory) {
Mark Otto's avatar
dist v5    
Mark Otto committed
7
8
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
XhmikosR's avatar
XhmikosR committed
9
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Polyfill = {}));
XhmikosR's avatar
XhmikosR committed
10
}(this, (function (exports) { 'use strict';
XhmikosR's avatar
XhmikosR committed
11
12
13

  /**
   * --------------------------------------------------------------------------
XhmikosR's avatar
XhmikosR committed
14
   * Bootstrap (v5.0.0-alpha2): util/index.js
XhmikosR's avatar
XhmikosR committed
15
   * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
XhmikosR's avatar
XhmikosR committed
16
17
18
19
20
21
22
23
24
25
26
27
   * --------------------------------------------------------------------------
   */
  var MAX_UID = 1000000;
  /**
   * --------------------------------------------------------------------------
   * Public Util Api
   * --------------------------------------------------------------------------
   */


  var getUID = function getUID(prefix) {
    do {
Mark Otto's avatar
Mark Otto committed
28
      prefix += Math.floor(Math.random() * MAX_UID);
XhmikosR's avatar
XhmikosR committed
29
30
31
32
33
    } while (document.getElementById(prefix));

    return prefix;
  };

Mark Otto's avatar
dist v5    
Mark Otto committed
34
35
  /* istanbul ignore file */
  exports.find = Element.prototype.querySelectorAll;
XhmikosR's avatar
XhmikosR committed
36
  exports.findOne = Element.prototype.querySelector; // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
Mark Otto's avatar
dist v5    
Mark Otto committed
37
38

  var defaultPreventedPreservedOnDispatch = function () {
XhmikosR's avatar
XhmikosR committed
39
    var e = new CustomEvent('Bootstrap', {
Mark Otto's avatar
dist v5    
Mark Otto committed
40
41
42
43
44
45
46
47
48
49
      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
50

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

Mark Otto's avatar
dist v5    
Mark Otto committed
53
54
  var supportScopeQuery = function () {
    var element = document.createElement('div');
XhmikosR's avatar
XhmikosR committed
55

Mark Otto's avatar
dist v5    
Mark Otto committed
56
57
    try {
      element.querySelectorAll(':scope *');
XhmikosR's avatar
XhmikosR committed
58
    } catch (_) {
Mark Otto's avatar
dist v5    
Mark Otto committed
59
60
61
62
63
64
65
66
67
68
69
70
71
      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
72

Mark Otto's avatar
dist v5    
Mark Otto committed
73
74
75
76
77
78
79
80
81
82
83
84
      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
85
        }
Mark Otto's avatar
dist v5    
Mark Otto committed
86
      }
XhmikosR's avatar
XhmikosR committed
87

Mark Otto's avatar
dist v5    
Mark Otto committed
88
89
90
91
92
93
94
      return nodeList;
    };

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

Mark Otto's avatar
dist v5    
Mark Otto committed
96
97
98
99
100
101
102
      var matches = exports.find.call(this, selector);

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

      return null;
XhmikosR's avatar
XhmikosR committed
103
    };
Mark Otto's avatar
dist v5    
Mark Otto committed
104
105
106
  }

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

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

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