1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-21 20:55:50 +02:00
This commit is contained in:
Mark Otto
2018-12-15 15:13:22 -08:00
committed by XhmikosR
parent ffd3402a92
commit ee72e7838d
34 changed files with 302 additions and 86 deletions

View File

@@ -192,6 +192,28 @@
}
}
}
},
findShadowRoot: function findShadowRoot(element) {
if (!document.documentElement.attachShadow) {
return null;
} // Can find the shadow root otherwise it'll return the document
if (typeof element.getRootNode === 'function') {
var root = element.getRootNode();
return root instanceof ShadowRoot ? root : null;
}
if (element instanceof ShadowRoot) {
return element;
} // when we don't find a shadow root
if (!element.parentNode) {
return null;
}
return Util.findShadowRoot(element.parentNode);
}
};
setTransitionEndSupport();
@@ -381,7 +403,7 @@
var Selector$1 = {
DATA_TOGGLE_CARROT: '[data-toggle^="button"]',
DATA_TOGGLE: '[data-toggle="buttons"]',
INPUT: 'input',
INPUT: 'input:not([type="hidden"])',
ACTIVE: '.active',
BUTTON: '.btn'
};
@@ -1475,7 +1497,7 @@
/**!
* @fileOverview Kickass library to create and place poppers near their reference elements.
* @version 1.14.5
* @version 1.14.6
* @license
* Copyright (c) 2016 Federico Zivolo and contributors
*
@@ -2225,8 +2247,8 @@
function getOuterSizes(element) {
var window = element.ownerDocument.defaultView;
var styles = window.getComputedStyle(element);
var x = parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
var y = parseFloat(styles.marginLeft) + parseFloat(styles.marginRight);
var x = parseFloat(styles.marginTop || 0) + parseFloat(styles.marginBottom || 0);
var y = parseFloat(styles.marginLeft || 0) + parseFloat(styles.marginRight || 0);
var result = {
width: element.offsetWidth + y,
height: element.offsetHeight + x
@@ -2676,6 +2698,52 @@
return options;
}
/**
* @function
* @memberof Popper.Utils
* @argument {Object} data - The data object generated by `update` method
* @argument {Boolean} shouldRound - If the offsets should be rounded at all
* @returns {Object} The popper's position offsets rounded
*
* The tale of pixel-perfect positioning. It's still not 100% perfect, but as
* good as it can be within reason.
* Discussion here: https://github.com/FezVrasta/popper.js/pull/715
*
* Low DPI screens cause a popper to be blurry if not using full pixels (Safari
* as well on High DPI screens).
*
* Firefox prefers no rounding for positioning and does not have blurriness on
* high DPI screens.
*
* Only horizontal placement and left/right values need to be considered.
*/
function getRoundedOffsets(data, shouldRound) {
var _data$offsets = data.offsets,
popper = _data$offsets.popper,
reference = _data$offsets.reference;
var isVertical = ['left', 'right'].indexOf(data.placement) !== -1;
var isVariation = data.placement.indexOf('-') !== -1;
var sameWidthOddness = reference.width % 2 === popper.width % 2;
var bothOddWidth = reference.width % 2 === 1 && popper.width % 2 === 1;
var noRound = function noRound(v) {
return v;
};
var horizontalToInteger = !shouldRound ? noRound : isVertical || isVariation || sameWidthOddness ? Math.round : Math.floor;
var verticalToInteger = !shouldRound ? noRound : Math.round;
return {
left: horizontalToInteger(bothOddWidth && !isVariation && shouldRound ? popper.left - 1 : popper.left),
top: verticalToInteger(popper.top),
bottom: verticalToInteger(popper.bottom),
right: horizontalToInteger(popper.right)
};
}
var isFirefox = isBrowser && /Firefox/i.test(navigator.userAgent);
/**
* @function
* @memberof Modifiers
@@ -2706,15 +2774,7 @@
position: popper.position
};
// Avoid blurry text by using full pixel integers.
// For pixel-perfect positioning, top/bottom prefers rounded
// values, while left/right prefers floored values.
var offsets = {
left: Math.floor(popper.left),
top: Math.round(popper.top),
bottom: Math.round(popper.bottom),
right: Math.floor(popper.right)
};
var offsets = getRoundedOffsets(data, window.devicePixelRatio < 2 || !isFirefox);
var sideA = x === 'bottom' ? 'top' : 'bottom';
var sideB = y === 'right' ? 'left' : 'right';
@@ -4444,7 +4504,7 @@
var isActive = $(parent).hasClass(ClassName$4.SHOW);
if (!isActive && (event.which !== ESCAPE_KEYCODE || event.which !== SPACE_KEYCODE) || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
var toggle = parent.querySelector(Selector$4.DATA_TOGGLE);
$(toggle).trigger('focus');
@@ -4750,6 +4810,8 @@
this._element.removeAttribute('aria-hidden');
this._element.setAttribute('aria-modal', true);
this._element.scrollTop = 0;
if (transition) {
@@ -4829,6 +4891,8 @@
this._element.setAttribute('aria-hidden', true);
this._element.removeAttribute('aria-modal');
this._isTransitioning = false;
this._showBackdrop(function () {
@@ -5295,7 +5359,8 @@
if (this.isWithContent() && this._isEnabled) {
$(this.element).trigger(showEvent);
var isInTheDom = $.contains(this.element.ownerDocument.documentElement, this.element);
var shadowRoot = Util.findShadowRoot(this.element);
var isInTheDom = $.contains(shadowRoot !== null ? shadowRoot : this.element.ownerDocument.documentElement, this.element);
if (showEvent.isDefaultPrevented() || !isInTheDom) {
return;
@@ -5316,7 +5381,9 @@
var attachment = this._getAttachment(placement);
this.addAttachmentClass(attachment);
var container = this.config.container === false ? document.body : $(document).find(this.config.container);
var container = this._getContainer();
$(tip).data(this.constructor.DATA_KEY, this);
if (!$.contains(this.element.ownerDocument.documentElement, this.tip)) {
@@ -5488,6 +5555,18 @@
}; // Private
_proto._getContainer = function _getContainer() {
if (this.config.container === false) {
return document.body;
}
if (Util.isElement(this.config.container)) {
return $(this.config.container);
}
return $(document).find(this.config.container);
};
_proto._getAttachment = function _getAttachment(placement) {
return AttachmentMap$1[placement.toUpperCase()];
};
@@ -6507,7 +6586,8 @@
var ClassName$a = {
FADE: 'fade',
HIDE: 'hide',
SHOW: 'show'
SHOW: 'show',
SHOWING: 'showing'
};
var DefaultType$7 = {
animation: 'boolean',
@@ -6554,6 +6634,10 @@
}
var complete = function complete() {
_this._element.classList.remove(ClassName$a.SHOWING);
_this._element.classList.add(ClassName$a.SHOW);
$(_this._element).trigger(Event$a.SHOWN);
if (_this._config.autohide) {
@@ -6561,7 +6645,9 @@
}
};
this._element.classList.add(ClassName$a.SHOW);
this._element.classList.remove(ClassName$a.HIDE);
this._element.classList.add(ClassName$a.SHOWING);
if (this._config.animation) {
var transitionDuration = Util.getTransitionDurationFromElement(this._element);
@@ -6622,6 +6708,8 @@
var _this4 = this;
var complete = function complete() {
_this4._element.classList.add(ClassName$a.HIDE);
$(_this4._element).trigger(Event$a.HIDDEN);
};