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

Fix various issues with slots #933

Merged
merged 44 commits into from
Jan 17, 2024
Merged

Fix various issues with slots #933

merged 44 commits into from
Jan 17, 2024

Conversation

MoustaphaDev
Copy link
Member

@MoustaphaDev MoustaphaDev commented Jan 3, 2024

Changes

Previously, using variables as slot names within loops was not possible because the slot object (specifically, the slot key) wasn't printed in the same location as the slotted elements.

This PR addresses this issue by refactoring the slot printing logic to ensure that the slot object is printed alongside the slotted elements when a dynamic slot name is used.

The other issues were fortuitously fixed with the refactor

Testing

Added test cases covering each issue

Docs

This wasn't possible before so we should probably document this. I'll make a docs PR

Copy link

changeset-bot bot commented Jan 3, 2024

🦋 Changeset detected

Latest commit: 97ce7ae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/compiler Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@MoustaphaDev

This comment was marked as outdated.

This comment was marked as outdated.

@MoustaphaDev MoustaphaDev force-pushed the feat/dynamic-slot-names branch from c5ebcf5 to bb95980 Compare January 10, 2024 19:03
@MoustaphaDev

This comment was marked as outdated.

This comment was marked as outdated.

@MoustaphaDev

This comment was marked as outdated.

This comment was marked as outdated.

@MoustaphaDev MoustaphaDev marked this pull request as ready for review January 12, 2024 20:33
@MoustaphaDev MoustaphaDev changed the title WIP: dynamic slot names experiment Fix various issues with slots Jan 12, 2024
Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

Phenomenal work! Tests look great and the code makes sense.

My only open question is about the mergeSlots function in core because there might be projects with an older Astro runtime but this release of the compiler. If everything is backwards compatible that's great, otherwise we might need to figure out the best way to handle this migration.

@MoustaphaDev
Copy link
Member Author

MoustaphaDev commented Jan 17, 2024

Yes, this is backwards compatible as it doesn't break any current slot functionality. Only users on older Astro versions attempting to use this feature will encounter issues (which they of course did even before this release if they tried to). I can make a PR to docs to communicate that clearly

@natemoo-re natemoo-re merged commit db13db9 into main Jan 17, 2024
5 checks passed
@natemoo-re natemoo-re deleted the feat/dynamic-slot-names branch January 17, 2024 21:20
MoustaphaDev added a commit that referenced this pull request Feb 5, 2024
Princesseuh pushed a commit that referenced this pull request Feb 6, 2024
…" (#963)

* test(#955): add failing test

* test(#955): add another failing test

* test: whoops it actually passes

* Revert "Fix slot regression when there are multiple expressions (#952)"

This reverts commit 418558c.

* Revert "Fix various issues with slots (#933)"

This reverts commit db13db9.

* chore: changeset

* chore: remove slot parens in test

* test: update test

* chore: remove slot parens in test

* test: add test for #959

---------

Co-authored-by: Nate Moore <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants