-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Astro Island Not Passing Attributes to Sub-Components, Rendering Twice, Issues With Lit #5304
Comments
If you have a reactive property it sets the property rather than the attribute. This is because some properties have to be rendered as props. What problem is caused by not setting the attribute? |
Same issue reported here: #6342 Did a little investigation and I think this is a Lit bug. It happens simply by having: <script>
import "lit";
</script> I think what is happening is there is a race condition here. I think that perhaps Lit is rendering before the HTML children have been appended, so it doesn't see that they are there. That is my theory at least. It does seem unrelated to anything Astro is doing though. Going to ping @e111077 if he wants to take a look, the example in #6342 is a pretty good reduction, but you can remove the client component and just have a |
This is a composition issue on the Astro side. When you include the Astro Lit integration, you should be inserting Unfortunately I do not know how to do this in the Lit integration. But there are 2 workarounds:
In Astro, it's expected that framework components should be loaded this way Hopefully there's a way an integration can inject a script to the top of the page, because in that case, loading the lit integration, it should just load the hydration support shim UPDATE: I updated the examples to use the lit client:only directive on a vanilla WC and it also seems to work in the general case |
Ah, we do have the hydration script, perhaps that is not being added correctly? I'll look into this tomorrow, thanks for the research @e111077 |
It might not be loaded early enough, and inline scripts may be injecting before it, or alternatively, it could be how HMR is doing things in relation to loading a Lit element without the |
As mentioned above by @e111077 inline scripts that query the document doesn't work with the |
clarification, the inline scripts i'm talking about – they may be loading the lit module before the lit experimental-hydrate module is loaded. This will cause Lit to skip the hydration step altogether, causing the double rendering. A workaround for now can be to simply import the hydration script, it won't be any extra bytes over the wire as long as you eventually have an astro lit component (which you will because that's what's ultimately causing this failure) |
When running |
+1 we are also experiencing this issue in a component on a live website. Following 👀 |
any progress? |
I think i found one of the problems: If i have a component (A) which is included in the astro page with a directive "client:visible" i will have duplicate output of the component (B), which is nested in component (A), as long as i do the import of component (B) before a instance of (A) exists. This does not work:Component A
Component B
This does work:Doing a dynamic import in the connectedCallback does solve the problem.
Component B
I hope that helps somehow. |
Im using React, and this has happened to 2 of my users consistently on a Chrome browser. Thing is I cant really replicate it locally and its a really reallyyyy weird bug |
Some of the issues pointed out in the original description seem to have been fixed. Facts as of today:
The "not passing props to attributes" seems to have been fixed at some point: Since importing manually is not something we document, my view is that the remaining issue would be a corner case that can be avoided by importing |
Agree with @lilnasy in that many of these issues have been fixed. Going to close as it's difficult to try and fix the remaining issues without a clear example of them. I would suggest that anyone that still has issues related to these in the Lit renderer please create a new issue specifically for them. |
I've filed a new issue for this including a reproducible example: #12198 |
What version of
astro
are you using?1.6.3
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
CodeSandbox
Describe the Bug
When using client directives in astro, it's not rendering attributes. On codesandbox, it's not even passing them when importing as a script. It's also rendering components twice when importing through a normal script tag. I've experienced this a little bit when running locally rarely. Also, when defined in typescript, components aren't hydrating. Using JS it works. Just check out the codesandbox example and you'll see what i mean.
Link to Minimal Reproducible Example
https://codesandbox.io/s/inspiring-agnesi-8h0z1d?file=/src/pages/index.astro
Participation
The text was updated successfully, but these errors were encountered: