This commit is contained in:
Mark Otto 2018-09-17 12:34:34 -07:00
parent 928ebd8925
commit b68ea572da
27 changed files with 97 additions and 167 deletions

View file

@ -140,24 +140,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) {
@ -1164,7 +1153,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) {
@ -1301,7 +1294,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
@ -1322,12 +1315,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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long