diff options
author | Mark Otto <markdotto@gmail.com> | 2017-10-25 22:35:07 +0300 |
---|---|---|
committer | Mark Otto <markdotto@gmail.com> | 2017-10-25 22:35:07 +0300 |
commit | 2e920625395334c8211bff86daed7ffbf21a1f8f (patch) | |
tree | 31ff10a5f2608218e2509357ecb280b9608146c8 /dist/js/bootstrap.bundle.js | |
parent | 8c587d42805af03f2d543ae93cfe05c739feb728 (diff) |
dist
Diffstat (limited to 'dist/js/bootstrap.bundle.js')
-rw-r--r-- | dist/js/bootstrap.bundle.js | 102 |
1 files changed, 48 insertions, 54 deletions
diff --git a/dist/js/bootstrap.bundle.js b/dist/js/bootstrap.bundle.js index e1b14ddd03..5f33f9c07b 100644 --- a/dist/js/bootstrap.bundle.js +++ b/dist/js/bootstrap.bundle.js @@ -1379,7 +1379,7 @@ var Collapse = function ($$$1) { /**! * @fileOverview Kickass library to create and place poppers near their reference elements. - * @version 1.12.5 + * @version 1.12.6 * @license * Copyright (c) 2016 Federico Zivolo and contributors * @@ -1401,22 +1401,7 @@ var Collapse = function ($$$1) { * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -var nativeHints = ['native code', '[object MutationObserverConstructor]']; - -/** - * Determine if a function is implemented natively (as opposed to a polyfill). - * @method - * @memberof Popper.Utils - * @argument {Function | undefined} fn the function to check - * @returns {Boolean} - */ -var isNative = (function (fn) { - return nativeHints.some(function (hint) { - return (fn || '').toString().indexOf(hint) > -1; - }); -}); - -var isBrowser = typeof window !== 'undefined'; +var isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined'; var longerTimeoutBrowsers = ['Edge', 'Trident', 'Firefox']; var timeoutDuration = 0; for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { @@ -1427,26 +1412,16 @@ for (var i = 0; i < longerTimeoutBrowsers.length; i += 1) { } function microtaskDebounce(fn) { - var scheduled = false; - var i = 0; - var elem = document.createElement('span'); - - // MutationObserver provides a mechanism for scheduling microtasks, which - // are scheduled *before* the next task. This gives us a way to debounce - // a function but ensure it's called *before* the next paint. - var observer = new MutationObserver(function () { - fn(); - scheduled = false; - }); - - observer.observe(elem, { attributes: true }); - + var called = false; return function () { - if (!scheduled) { - scheduled = true; - elem.setAttribute('x-index', i); - i = i + 1; // don't use compund (+=) because it doesn't get optimized in V8 + if (called) { + return; } + called = true; + Promise.resolve().then(function () { + called = false; + fn(); + }); }; } @@ -1463,11 +1438,7 @@ function taskDebounce(fn) { }; } -// It's common for MutationObserver polyfills to be seen in the wild, however -// these rely on Mutation Events which only occur when an element is connected -// to the DOM. The algorithm used in this module does not use a connected element, -// and so we must ensure that a *native* MutationObserver is available. -var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserver); +var supportsMicroTasks = isBrowser && window.Promise; /** * Create a debounced version of a method, that's asynchronously deferred @@ -1478,7 +1449,7 @@ var supportsNativeMutationObserver = isBrowser && isNative(window.MutationObserv * @argument {Function} fn * @returns {Function} */ -var debounce = supportsNativeMutationObserver ? microtaskDebounce : taskDebounce; +var debounce = supportsMicroTasks ? microtaskDebounce : taskDebounce; /** * Check if the given variable is a function @@ -1531,10 +1502,18 @@ function getParentNode(element) { */ function getScrollParent(element) { // Return body, `getScroll` will take care to get the correct `scrollTop` from it - if (!element || ['HTML', 'BODY', '#document'].indexOf(element.nodeName) !== -1) { + if (!element) { return window.document.body; } + switch (element.nodeName) { + case 'HTML': + case 'BODY': + return element.ownerDocument.body; + case '#document': + return element.body; + } + // Firefox want us to check `-x` and `-y` variations as well var _getStyleComputedProp = getStyleComputedProperty(element), @@ -1562,6 +1541,10 @@ function getOffsetParent(element) { var nodeName = offsetParent && offsetParent.nodeName; if (!nodeName || nodeName === 'BODY' || nodeName === 'HTML') { + if (element) { + return element.ownerDocument.documentElement; + } + return window.document.documentElement; } @@ -1657,8 +1640,8 @@ function getScroll(element) { var nodeName = element.nodeName; if (nodeName === 'BODY' || nodeName === 'HTML') { - var html = window.document.documentElement; - var scrollingElement = window.document.scrollingElement || html; + var html = element.ownerDocument.documentElement; + var scrollingElement = element.ownerDocument.scrollingElement || html; return scrollingElement[upperSide]; } @@ -1907,7 +1890,7 @@ function getOffsetRectRelativeToArbitraryNode(children, parent) { } function getViewportOffsetRectRelativeToArtbitraryNode(element) { - var html = window.document.documentElement; + var html = element.ownerDocument.documentElement; var relativeOffset = getOffsetRectRelativeToArbitraryNode(element, html); var width = Math.max(html.clientWidth, window.innerWidth || 0); var height = Math.max(html.clientHeight, window.innerHeight || 0); @@ -1968,10 +1951,10 @@ function getBoundaries(popper, reference, padding, boundariesElement) { if (boundariesElement === 'scrollParent') { boundariesNode = getScrollParent(getParentNode(popper)); if (boundariesNode.nodeName === 'BODY') { - boundariesNode = window.document.documentElement; + boundariesNode = popper.ownerDocument.documentElement; } } else if (boundariesElement === 'window') { - boundariesNode = window.document.documentElement; + boundariesNode = popper.ownerDocument.documentElement; } else { boundariesNode = boundariesElement; } @@ -2212,10 +2195,11 @@ function runModifiers(modifiers, data, ends) { var modifiersToRun = ends === undefined ? modifiers : modifiers.slice(0, findIndex(modifiers, 'name', ends)); modifiersToRun.forEach(function (modifier) { - if (modifier.function) { + if (modifier['function']) { + // eslint-disable-line dot-notation console.warn('`modifier.function` is deprecated, use `modifier.fn`!'); } - var fn = modifier.function || modifier.fn; + var fn = modifier['function'] || modifier.fn; // eslint-disable-line dot-notation if (modifier.enabled && isFunction(fn)) { // Add properties to offsets to make them a complete clientRect object // we do this before each modifier to make sure the previous one doesn't @@ -2342,9 +2326,19 @@ function destroy() { return this; } +/** + * Get the window associated with the element + * @argument {Element} element + * @returns {Window} + */ +function getWindow(element) { + var ownerDocument = element.ownerDocument; + return ownerDocument ? ownerDocument.defaultView : window; +} + function attachToScrollParents(scrollParent, event, callback, scrollParents) { var isBody = scrollParent.nodeName === 'BODY'; - var target = isBody ? window : scrollParent; + var target = isBody ? scrollParent.ownerDocument.defaultView : scrollParent; target.addEventListener(event, callback, { passive: true }); if (!isBody) { @@ -2362,7 +2356,7 @@ function attachToScrollParents(scrollParent, event, callback, scrollParents) { function setupEventListeners(reference, options, state, updateBound) { // Resize event listener on window state.updateBound = updateBound; - window.addEventListener('resize', state.updateBound, { passive: true }); + getWindow(reference).addEventListener('resize', state.updateBound, { passive: true }); // Scroll event listener on scroll parents var scrollElement = getScrollParent(reference); @@ -2393,7 +2387,7 @@ function enableEventListeners() { */ function removeEventListeners(reference, state) { // Remove resize event listener on window - window.removeEventListener('resize', state.updateBound); + getWindow(reference).removeEventListener('resize', state.updateBound); // Remove scroll event listener on scroll parents state.scrollParents.forEach(function (target) { @@ -3695,8 +3689,8 @@ var Popper = function () { }; // get reference and popper elements (allow jQuery wrappers) - this.reference = reference.jquery ? reference[0] : reference; - this.popper = popper.jquery ? popper[0] : popper; + this.reference = reference && reference.jquery ? reference[0] : reference; + this.popper = popper && popper.jquery ? popper[0] : popper; // Deep merge modifiers options this.options.modifiers = {}; |