Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do a major cleanup in Collapse.js #34220

Merged
merged 10 commits into from
Jul 29, 2021
Merged

Do a major cleanup in Collapse.js #34220

merged 10 commits into from
Jul 29, 2021

Conversation

GeoSot
Copy link
Member

@GeoSot GeoSot commented Jun 10, 2021

  • streamline _getConfig & interface
  • Remove redundant check on data-toggle click, as it was assuming that trigger element would own separate config than the collapse itself (wasn't documented)
  • Use helper function to check show
  • Remove helper for isTransitioning
  • Use forEach for all iterations
  • refactor privatef unction to use it in more cases
  • initialize array variable properly
  • Simplify check for children and make it generic
  • remove duplicated Selector.find
  • keep parent only as element
  • simplify initialization on data-toggle click
  • transfer interface inside jQueryInterface

NOTE for reviewers:

Better review it, commit by commit. It will help you with the proper message and will guide you with sanity to follow the logic

Closes #34408

@GeoSot GeoSot marked this pull request as ready for review June 10, 2021 00:14
@GeoSot GeoSot requested a review from a team as a code owner June 10, 2021 00:14
@GeoSot GeoSot changed the title Do a major cleanup in Collapse,js Do a major cleanup in Collapse.js Jun 10, 2021
@alecpl
Copy link
Contributor

alecpl commented Jun 10, 2021

Why introduce a BC break with "keep parent only as element"? Some other components support string|element items.

@GeoSot
Copy link
Member Author

GeoSot commented Jun 10, 2021

Why introduce a BC break with "keep parent only as element"? Some other components support string|element items.

Hmmm I don't think it is a breaking change, as the tests hasn't been change at all.

The reality is, that now, the component acts as chameleon, parent may be string, may be element may be false empty string, to loose approach that causes many checks inside, and typeCheck passes as empty string is still a string

with this MR, getElement is used to initialize parent, so it still supports strings. However I am not sure if it has to be written on config object somehow

@alecpl
Copy link
Contributor

alecpl commented Jun 10, 2021

Why introduce a BC break with "keep parent only as element"? Some other components support string|element items.

Hmmm I don't think it is a breaking change, as the tests hasn't been change at all.

That means the tests aren't complete. This is a public API: https://getbootstrap.com/docs/5.0/components/collapse/#options

@GeoSot
Copy link
Member Author

GeoSot commented Jun 10, 2021

May I don't express it well. It still accepts string selectors and jQuery objects. In its internals it keeps the vanilla js element and only.

And the real check is if the element exists or not. (right?)

@alecpl
Copy link
Contributor

alecpl commented Jun 10, 2021

I may misinterpreted the code, I don't know it well. If these type defs are for internal use only, then there's no problem.

@twbs twbs deleted a comment from tungphan995 Jun 10, 2021
@GeoSot GeoSot force-pushed the gs-collapse-cleanups branch from 98c281f to c5227b2 Compare June 18, 2021 08:57
Copy link
Member

@mdo mdo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't speak to the JS changes, but clicking around, things look good inn the docs!

/cc @twbs/js-review for proper review

@mdo
Copy link
Member

mdo commented Jul 12, 2021

Ping @twbs/js-review for this one :)

@GeoSot GeoSot force-pushed the gs-collapse-cleanups branch from f2ea075 to e83d2de Compare July 20, 2021 10:26
@XhmikosR XhmikosR force-pushed the gs-collapse-cleanups branch from e83d2de to cb9e0f9 Compare July 20, 2021 15:36
@GeoSot GeoSot force-pushed the gs-collapse-cleanups branch 2 times, most recently from 471b8bb to 2e7e0ec Compare July 26, 2021 23:27
@XhmikosR XhmikosR force-pushed the gs-collapse-cleanups branch 3 times, most recently from 4c35ee8 to f3cd631 Compare July 28, 2021 13:51
@GeoSot GeoSot force-pushed the gs-collapse-cleanups branch from f3cd631 to 9edca4f Compare July 28, 2021 22:32
GeoSot added 9 commits July 29, 2021 16:04
Previously, it was assumed that the trigger element would have its own separate config than the collapse element itself.
Also, remove the `isTransitioning()` helper.
Also, remove a few redundant checks since we already check for it in `_addAriaAndCollapsedClass()`.
@XhmikosR XhmikosR force-pushed the gs-collapse-cleanups branch from 9edca4f to 80c50e2 Compare July 29, 2021 13:12
@XhmikosR XhmikosR merged commit 2bf32ad into main Jul 29, 2021
@XhmikosR XhmikosR deleted the gs-collapse-cleanups branch July 29, 2021 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Collapse elements do not respect data attribute configurations when manually instantiated
4 participants