-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Pass children to client components even if they do not render them #2588
Conversation
🦋 Changeset detectedLatest commit: ad69806 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, clever fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woah. Clever fix! LGTM.
if(fragment == null) { | ||
// If there is no child fragment, check to see if there is a template. | ||
// This happens if children were passed but the client component did not render any. | ||
let template = roots[0].querySelector(`template[data-astro-template]`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self, this is going to check for this template any time there is not an astro-fragment. We can probably short circuit this check so it's only done when needed.
c369396
to
1d15dc3
Compare
Put this back to draft as I want to make one small change but need to test it locally first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, that's a very cool fix!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
…ithastro#2588) * Pass children to client components even if they do not render them * Handle when no children are provided * Adds a changeset * Use roots directly i guess * Use an attribute to signal that the template is needed
Changes
<astro-fragment>
but there are children, we know that means they did not render the children.<template data-astro-template>
inside of the<astro-root>
. In the client the HTML inside of this template becomes the children passed to the client component.Testing
Tests added.
Docs
Not needed, bug fix.