mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
Fix Lit integration hydration ordering (#9018)
* Provide renderer instance to `customElementHostStack` * Add changeset
This commit is contained in:
parent
3c17b59f2d
commit
23c9a30ad8
3 changed files with 9 additions and 1 deletions
5
.changeset/spotty-rings-crash.md
Normal file
5
.changeset/spotty-rings-crash.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'@astrojs/lit': patch
|
||||
---
|
||||
|
||||
Fix hydration ordering of nested custom elements. Child components will now wait for their parents to hydrate before hydrating themselves.
|
|
@ -62,7 +62,7 @@ function* render(Component, attrs, slots) {
|
|||
const shadowContents = instance.renderShadow({
|
||||
elementRenderers: [LitElementRenderer],
|
||||
customElementInstanceStack: [instance],
|
||||
customElementHostStack: [],
|
||||
customElementHostStack: [instance],
|
||||
deferHydration: false,
|
||||
});
|
||||
if (shadowContents !== undefined) {
|
||||
|
|
|
@ -112,6 +112,9 @@ describe('renderToStaticMarkup', () => {
|
|||
const render = await renderToStaticMarkup(tagName);
|
||||
const $ = cheerio.load(render.html);
|
||||
expect($(`${tagName} template`).text()).to.contain('child');
|
||||
// Child component should have `defer-hydration` attribute so it'll only
|
||||
// hydrate after the parent hydrates
|
||||
expect($(childTagName).attr('defer-hydration')).to.equal('');
|
||||
});
|
||||
|
||||
it('should render DSD attributes based on shadowRootOptions', async () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue