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

client:only causes component contents to be deleted in output (v3) #8337

Closed
1 task
xiBread opened this issue Aug 31, 2023 · 3 comments
Closed
1 task

client:only causes component contents to be deleted in output (v3) #8337

xiBread opened this issue Aug 31, 2023 · 3 comments
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: vue Related to Vue (scope)

Comments

@xiBread
Copy link
Contributor

xiBread commented Aug 31, 2023

Astro Info

Astro                    v3.0.5
Node                     v20.5.1
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             @astrojs/tailwind
                         @astrojs/vue
                         @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Building a project with components using the client:only directive results in its contents disappearing, e.g., building this:

<!-- Component.vue -->
<template>
	<div class="hello">
		Lorem ipsum.
	</div>
</template>

<!-- index.astro -->
<Component client:only="vue">

↓↓↓

<!-- dist/index.html -->
<astro-island ...></astro-island>

If I add a <slot /> to the component, the slotted content is placed, but all other elements are ignored:

<!-- Slotted.vue -->
<template>
	<div class="a">
		<slot />
	</div>

	<div class="b"></div>
</template>

<!-- index.astro -->
<Slotted client:only="vue">
	<p>Lorem ipsum</p>
</Slotted>

↓↓↓

<!-- dist/index.html -->
<astro-island ...>
	<template data-astro-template>
		<p>Lorem ipsum</p>
	</template>
</astro-island>

Screenshots from my project:

v2.10.14
v3.0.5
Console output

What's the expected result?

The contents are preserved.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-4wkbtj?file=dist%2Findex.html

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 31, 2023
@natemoo-re natemoo-re added pkg: vue Related to Vue (scope) - P4: important Violate documented behavior or significantly impacts performance (priority) labels Aug 31, 2023
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Aug 31, 2023
@natemoo-re
Copy link
Member

This one may have been my fault! I refactored the Vue renderer in #8264 and may have caused a regression for client:only.

I'm pretty sure you can pin to @astrojs/[email protected] until we get this fixed!

@xiBread
Copy link
Contributor Author

xiBread commented Sep 2, 2023

Upon further testing, I was able to get the above reproduction working using @astrojs/node, so this could be an issue with the Vercel integration.

lemredd added a commit to lemredd/site that referenced this issue Sep 4, 2023
The `[email protected]` has an active issue with regards to client components.
withastro/astro#8337
@xiBread
Copy link
Contributor Author

xiBread commented Sep 4, 2023

This seems to have been fixed in one of the latest releases.

@xiBread xiBread closed this as completed Sep 4, 2023
lemredd added a commit to lemredd/site that referenced this issue Sep 18, 2023
Seems that the latest release have fixed the issue regarding
`client:only` components, though I do not know which specific commit/s
from `Astro`'s codebase lead to this fix.
withastro/astro#8337 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly impacts performance (priority) pkg: vue Related to Vue (scope)
Projects
None yet
Development

No branches or pull requests

2 participants