Skip to content

Commit 7223813

Browse files
author
Chris Hawes
committed
jqlite-friendly fix for issue #85
Fix issue where nested elements within a ba-open (etc) element would not open the thing that was supposed to be opened.
1 parent 3a304b4 commit 7223813

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

js/angular/components/common/common.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,21 @@
201201
element.on('click', function(e) {
202202
var tar = e.target, avoid, activeElements, closedElements, i;
203203

204-
// check if clicked target is designated to open/close another component
204+
// check if clicked target or any of its ancestors is designated to open/close
205+
// another component
205206
avoid = ['ba-toggle', 'ba-hard-toggle', 'ba-open', 'ba-close'].filter(function(e){
206-
return tar.closest('*[' + e + ']') !== null;
207+
var parentElement = tar, hasAttr = false;
208+
209+
while (parentElement && typeof(parentElement.getAttribute) === 'function') {
210+
var attrVal = parentElement.getAttribute(e);
211+
if (typeof(attrVal) !== 'undefined' && attrVal !== null) {
212+
hasAttr = true;
213+
break;
214+
}
215+
parentElement = parentElement.parentNode;
216+
}
217+
218+
return hasAttr;
207219
});
208220
if(avoid.length > 0) {
209221
// do nothing

0 commit comments

Comments
 (0)