Skip to content

Commit 322709d

Browse files
committed
M2C-22619 Add check if found elements are not nested to prevent from processing panels incorrectly
1 parent 8132944 commit 322709d

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

lib/web/mage/tabs.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,49 @@ define([
102102
* @private
103103
*/
104104
_processPanels: function () {
105-
this.contents = this.element.children(this.options.content);
105+
var isNotNested = this._isNotNested.bind(this);
106106

107-
this.collapsibles = this.element.children(this.options.collapsibleElement);
107+
this.contents = this.element
108+
.find(this.options.content)
109+
.filter(isNotNested);
110+
111+
this.collapsibles = this.element
112+
.find(this.options.collapsibleElement)
113+
.filter(isNotNested);
108114

109115
this.collapsibles
110116
.attr('role', 'presentation')
111117
.parent()
112118
.attr('role', 'tablist');
113119

114-
this.headers = this.element.children(this.options.header);
120+
this.headers = this.element
121+
.find(this.options.header)
122+
.filter(isNotNested);
115123

116124
if (this.headers.length === 0) {
117125
this.headers = this.collapsibles;
118126
}
119-
this.triggers = this.element.children(this.options.trigger);
127+
this.triggers = this.element
128+
.find(this.options.trigger)
129+
.filter(isNotNested);
120130

121131
if (this.triggers.length === 0) {
122132
this.triggers = this.headers;
123133
}
124134
this._callCollapsible();
125135
},
126136

137+
/**
138+
* @param {HTMLElement} elem
139+
* @private
140+
* @return {Boolean}
141+
*/
142+
_isNotNested: function (index, element) {
143+
var parentContent = $(element).parents(this.options.content);
144+
145+
return !parentContent.length || !this.element.find(parentContent).length;
146+
},
147+
127148
/**
128149
* Setting the disabled and active tabs and calling instantiation of collapsible
129150
* @private

0 commit comments

Comments
 (0)