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(slots): consume eagerly rendered slot after one use #8929

Merged
merged 5 commits into from
Nov 1, 2023

Conversation

lilnasy
Copy link
Contributor

@lilnasy lilnasy commented Oct 26, 2023

Changes

Testing

Added a case to an existing fixture.

Docs

Does not affect usage.

@changeset-bot
Copy link

changeset-bot bot commented Oct 26, 2023

🦋 Changeset detected

Latest commit: 4dcc09c

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

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

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Oct 26, 2023
@lilnasy lilnasy changed the title render slots lazily fix(slots): consume eagerly rendered slot after one use Oct 26, 2023
@github-actions github-actions bot added the pr: docs A PR that includes documentation for review label Oct 30, 2023
@lilnasy lilnasy marked this pull request as ready for review October 30, 2023 14:21
'astro': patch
---

Fixes an issue where a slot rendered multiple times resulted in the same output each time.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Fixes an issue where a slot rendered multiple times resulted in the same output each time.
Fixes an issue where rendering multiple slots resulted in the same output each time.

super-nit: "a slot" rendered multiple times makes me think it's the same one slot, so the output should be the same! Would this be a correct description? (non-blocking, though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is the same one slot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now that you bring it up though, I think there is room for clarification. Before this PR, the first render was reused when users tried to manually render the same slot multiple times.

Copy link
Member

Choose a reason for hiding this comment

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

OK, then maybe something like.... (wordy, but trying to see if this is the right idea)

Fixes an issue where a slot rendered multiple times incorrectly used the same initial rendering for each instance

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.

Implementation LGTM! I think it could be refactored to be slightly more clear, but it's up to you. I wouldn't block a merge as-is.

packages/astro/src/runtime/server/render/astro/instance.ts Outdated Show resolved Hide resolved
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

LGTM!

@lilnasy lilnasy merged commit 2da33b7 into withastro:main Nov 1, 2023
13 checks passed
@astrobot-houston astrobot-houston mentioned this pull request Nov 1, 2023
@lilnasy lilnasy deleted the fix/7068 branch November 12, 2023 01:22
natemoo-re pushed a commit that referenced this pull request Nov 22, 2023
* render slots lazily

* add test

* add changeset

* refactor

* reword changeset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope) pr: docs A PR that includes documentation for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different behavior with slot vs Astro.slots.render
4 participants