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-02-11 14:53:29 -08:00
parent f81f419b22
commit e373fbea92
24 changed files with 175 additions and 80 deletions

View File

@@ -68,7 +68,7 @@ var Util = function ($$$1) {
var MAX_UID = 1000000; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType(obj) {
return {}.toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
}
function getSpecialTransitionEndEvent() {
@@ -118,13 +118,6 @@ var Util = function ($$$1) {
$$$1.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
}
}
function escapeId(selector) {
// We escape IDs in case of special selectors (selector = '#myId:something')
// $.escapeSelector does not exist in jQuery < 3
selector = typeof $$$1.escapeSelector === 'function' ? $$$1.escapeSelector(selector).substr(1) : selector.replace(/(:|\.|\[|\]|,|=|@)/g, '\\$1');
return selector;
}
/**
* --------------------------------------------------------------------------
* Public Util Api
@@ -147,11 +140,6 @@ var Util = function ($$$1) {
if (!selector || selector === '#') {
selector = element.getAttribute('href') || '';
} // If it's an ID
if (selector.charAt(0) === '#') {
selector = escapeId(selector);
}
try {
@@ -3901,12 +3889,14 @@ var Dropdown = function ($$$1) {
var Default = {
offset: 0,
flip: true,
boundary: 'scrollParent'
boundary: 'scrollParent',
reference: 'toggle'
};
var DefaultType = {
offset: '(number|string|function)',
flip: 'boolean',
boundary: '(string|element)'
boundary: '(string|element)',
reference: '(string|element)'
/**
* ------------------------------------------------------------------------
* Class Definition
@@ -3967,11 +3957,15 @@ var Dropdown = function ($$$1) {
throw new TypeError('Bootstrap dropdown require Popper.js (https://popper.js.org)');
}
var element = this._element; // For dropup with alignment we use the parent as popper container
var referenceElement = this._element;
if ($$$1(parent).hasClass(ClassName.DROPUP)) {
if ($$$1(this._menu).hasClass(ClassName.MENULEFT) || $$$1(this._menu).hasClass(ClassName.MENURIGHT)) {
element = parent;
if (this._config.reference === 'parent') {
referenceElement = parent;
} else if (Util.isElement(this._config.reference)) {
referenceElement = this._config.reference; // Check if it's jQuery element
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
} // If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
@@ -3982,7 +3976,7 @@ var Dropdown = function ($$$1) {
$$$1(parent).addClass(ClassName.POSITION_STATIC);
}
this._popper = new Popper(element, this._menu, this._getPopperConfig());
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
} // If this is a touch-enabled device we add extra
// empty mouseover listeners to the body's immediate children;
// only needed because of broken event delegation on iOS