aboutsummaryrefslogtreecommitdiff
path: root/dist/js/bootstrap.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2018-09-17 12:34:34 -0700
committerMark Otto <[email protected]>2018-09-17 12:34:34 -0700
commitb68ea572da7b16232b04820bfa1035c506af8bb2 (patch)
treee33670e98e1011e19925bbdae3b9cf7cbc9a5b92 /dist/js/bootstrap.js
parent928ebd89254300aee284fc78b84c8a57de188d71 (diff)
downloadbootstrap-b68ea572da7b16232b04820bfa1035c506af8bb2.tar.xz
bootstrap-b68ea572da7b16232b04820bfa1035c506af8bb2.zip
dist
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r--dist/js/bootstrap.js33
1 files changed, 12 insertions, 21 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js
index fe19a1086..39bbd8d9f 100644
--- a/dist/js/bootstrap.js
+++ b/dist/js/bootstrap.js
@@ -141,24 +141,13 @@
},
getSelectorFromElement: function getSelectorFromElement(element) {
var selector = element.getAttribute('data-target');
- var method = 'querySelector';
if (!selector || selector === '#') {
- selector = (element.getAttribute('href') || '').trim();
+ var hrefAttr = element.getAttribute('href');
+ selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
}
- var validSelector = selector;
-
- if (selector.charAt(0) === '#' && selector.indexOf(',') === -1) {
- selector = selector.substr(1);
- method = 'getElementById';
- }
-
- try {
- return document[method](selector) ? validSelector : null;
- } catch (err) {
- return null;
- }
+ return selector && document.querySelector(selector) ? selector : null;
},
getTransitionDurationFromElement: function getTransitionDurationFromElement(element) {
if (!element) {
@@ -1165,7 +1154,11 @@
if (this._parent) {
actives = [].slice.call(this._parent.querySelectorAll(Selector.ACTIVES)).filter(function (elem) {
- return elem.getAttribute('data-parent') === _this._config.parent;
+ if (typeof _this._config.parent === 'string') {
+ return elem.getAttribute('data-parent') === _this._config.parent;
+ }
+
+ return elem.classList.contains(ClassName.COLLAPSE);
});
if (actives.length === 0) {
@@ -1302,7 +1295,7 @@
_proto._getParent = function _getParent() {
var _this3 = this;
- var parent = null;
+ var parent;
if (Util.isElement(this._config.parent)) {
parent = this._config.parent; // It's a jQuery object
@@ -1323,12 +1316,10 @@
};
_proto._addAriaAndCollapsedClass = function _addAriaAndCollapsedClass(element, triggerArray) {
- if (element) {
- var isOpen = $$$1(element).hasClass(ClassName.SHOW);
+ var isOpen = $$$1(element).hasClass(ClassName.SHOW);
- if (triggerArray.length) {
- $$$1(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
- }
+ if (triggerArray.length) {
+ $$$1(triggerArray).toggleClass(ClassName.COLLAPSED, !isOpen).attr('aria-expanded', isOpen);
}
}; // Static