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

refactor: Deprecate conditionalSlot utility and getSlotted method #5380

Merged
merged 12 commits into from
Nov 16, 2022

Conversation

driskull
Copy link
Member

@driskull driskull commented Sep 23, 2022

Related Issue: #

Summary

refactor: Deprecate conditionalSlot utility.

  • Deprecates conditionalSlot utility class in favor of hasAssignedElement dom utility.
    • There's no need to setup mutation observers and forceUpdate when onSlotchange works perfectly.
    • The conditionalSlot utility class will not work if ComponentA slots into a slot in ComponentB.
  • Deprecates getSlotted utility function in favor of onSlotChange.

Example: Component has slotted elements

import { hasAssignedElement } from "../../utils/dom";
@State() mySlotHasElement: boolean;
<slot onSlotchange={(event) => this.mySlotHasElement = hasAssignedElement(event)) />}

Example: Getting slotted elements

import { getAssignedElements } from "../../utils/dom";
@State() mySlotElements: Element[];
<slot onSlotchange={(event) => this.mySlotElements = getAssignedElements(event)) />}

@github-actions github-actions bot added the refactor Issues tied to code that needs to be significantly reworked. label Sep 23, 2022
@driskull driskull changed the title refactor: Deprecate conditionalSlot utility. refactor: Deprecate conditionalSlot utility Sep 26, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

This PR has been automatically marked as stale because it has not had recent activity. Please close your PR if it is no longer relevant. Thank you for your contributions.

@github-actions github-actions bot added the Stale Issues or pull requests that have not had recent activity. label Oct 4, 2022
@driskull driskull marked this pull request as ready for review October 18, 2022 16:35
@driskull driskull requested a review from a team as a code owner October 18, 2022 16:35
@driskull driskull requested a review from jcfranco October 18, 2022 16:35
@driskull
Copy link
Member Author

driskull commented Nov 3, 2022

@jcfranco I can haz install?

@driskull driskull changed the title refactor: Deprecate conditionalSlot utility refactor: Deprecate conditionalSlot utility and getSlotted method Nov 15, 2022
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

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

Very nice! Good to merge once the new utils have tests.

src/utils/conditionalSlot.ts Outdated Show resolved Hide resolved
src/utils/dom.ts Outdated Show resolved Hide resolved
src/utils/dom.ts Outdated Show resolved Hide resolved
src/utils/dom.ts Outdated Show resolved Hide resolved
@driskull driskull merged commit 448337a into master Nov 16, 2022
@driskull driskull deleted the dris0000/deprecate-conditional-slot-component branch November 16, 2022 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Issues tied to code that needs to be significantly reworked. Stale Issues or pull requests that have not had recent activity.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants