Reverse #22138 and detach accordion from card without requiring 'data-children'#22251
Conversation
This reverts commit 21b537c.
…'data-children'
|
|
||
| if (this._parent) { | ||
| actives = $.makeArray($(this._parent).find(this._selectorActives)) | ||
| actives = $.makeArray($(this._parent).children().children(Selector.ACTIVES)) |
There was a problem hiding this comment.
I'm not sure if this is better or not, but you do a double find of children instead of one. So if they are a huge collapse it wont be fast as the previous PR
There was a problem hiding this comment.
The find() method in JQuery go through the whole tree of child (life child, grand-child, grand-grand-child).
The children() go through only one level. So 2 calls to children() will most likely be faster than find() in case there is content in the .collapse (that would be more than 2 level). Most likely there would be content in the .collapse.
In addition calling children() twice might actually be faster than ${childrenSelector} > .show, ${childrenSelector} > .collapsing as it would loop on the child nodes in the tree rather than calling Sizzle/querySelector.
There was a problem hiding this comment.
But frankly if there is a performance difference, one way or the other, it would be a matter nano seconds per collapsible. Unless you have an accordion with million of children the difference will be close to nothing.
I think the simplification for theBootstrap user (getting rid of data-children attribute) worth the few nano seconds that might be lost or gained.
|
Does any of this business with |
|
In both cases the selector will select only the direct child the accordion that is collapsible, i.e Maybe I can add a unit test for nested accordion. Would you prefer that in this PR or a different one ? |
|
Actually forget my previous comment. The current implementation will not work with nested accordion as the selector This PR will incidentally fix this issue as the |
|
@mdo, I added a unit test for nested accordions. It passes with this PR but doesn't in the current v4-dev. |
#22138 was merge in order to detach accordion from
.cardand is based on a new attributedata-childrenthat require to reference the class of the child.This PR reverse #22138 and implement a more simple solution that does not require any new attribute.
I initially wanted to give my feedback on the original PR, but somehow forgot and remembered when I saw it merged...