diff options
Diffstat (limited to 'dist/js/bootstrap.js')
-rw-r--r-- | dist/js/bootstrap.js | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/dist/js/bootstrap.js b/dist/js/bootstrap.js index fe19a1086e..39bbd8d9ff 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 |