-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix race condition with directive definitions (#4375)
- Loading branch information
Showing
16 changed files
with
128 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fixes race condition between directives being defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import preact from '@astrojs/preact'; | ||
|
||
export default { | ||
integrations: [preact()] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "@e2e/hydration-race", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "astro dev", | ||
"build": "astro build" | ||
}, | ||
"dependencies": { | ||
"astro": "workspace:*", | ||
"@astrojs/preact": "workspace:*" | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/astro/e2e/fixtures/hydration-race/src/components/Deeper.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
import One from './One.jsx'; | ||
--- | ||
|
||
<div> | ||
<span>Before one</span> | ||
<One name="One" client:idle /> | ||
</div> | ||
|
6 changes: 6 additions & 0 deletions
6
packages/astro/e2e/fixtures/hydration-race/src/components/Layout.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
import Wrapper from './Wrapper.astro'; | ||
--- | ||
|
||
<Wrapper /> | ||
<slot /> |
8 changes: 8 additions & 0 deletions
8
packages/astro/e2e/fixtures/hydration-race/src/components/One.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { h } from 'preact'; | ||
|
||
export default function({ name }) { | ||
const inTheClient = import.meta.env.SSR ? '' : ' in the client' | ||
return ( | ||
<div id={name.toLowerCase()}>Hello {name}{inTheClient}</div> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
packages/astro/e2e/fixtures/hydration-race/src/components/Wrapper.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
import One from './One.jsx'; | ||
import Deeper from './Deeper.astro'; | ||
--- | ||
|
||
|
||
<One name="Two" client:visible /> | ||
<Deeper /> |
15 changes: 15 additions & 0 deletions
15
packages/astro/e2e/fixtures/hydration-race/src/pages/slot.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
import Layout from '../components/Layout.astro'; | ||
import One from '../components/One.jsx'; | ||
--- | ||
<html> | ||
<head> | ||
<title>Testing</title> | ||
</head> | ||
<body> | ||
<One name="Four" client:idle /> | ||
<Layout> | ||
<One name="Three" client:visible /> | ||
</Layout> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { expect } from '@playwright/test'; | ||
import { testFactory } from './test-utils.js'; | ||
|
||
const test = testFactory({ | ||
root: './fixtures/hydration-race/', | ||
}); | ||
|
||
let devServer; | ||
|
||
test.beforeEach(async ({ astro }) => { | ||
devServer = await astro.startDevServer(); | ||
}); | ||
|
||
test.afterEach(async () => { | ||
await devServer.stop(); | ||
}); | ||
|
||
test.describe('Hydration race', () => { | ||
test('Islands inside of slots hydrate', async ({ page, astro }) => { | ||
await page.goto('/slot'); | ||
|
||
const html = await page.content(); | ||
|
||
const one = page.locator('#one'); | ||
await expect(one, 'updated text').toHaveText('Hello One in the client'); | ||
|
||
const two = page.locator('#two'); | ||
await expect(two, 'updated text').toHaveText('Hello Two in the client'); | ||
|
||
const three = page.locator('#three'); | ||
await expect(three, 'updated text').toHaveText('Hello Three in the client'); | ||
|
||
const four = page.locator('#four'); | ||
await expect(four, 'updated text').toHaveText('Hello Four in the client'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ | |
setTimeout(cb, 200); | ||
} | ||
}; | ||
window.dispatchEvent(new Event('astro:idle')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
await hydrate(); | ||
})(); | ||
}; | ||
window.dispatchEvent(new Event('astro:load')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ | |
} | ||
} | ||
}; | ||
window.dispatchEvent(new Event('astro:media')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
await hydrate(); | ||
})(); | ||
}; | ||
window.dispatchEvent(new Event('astro:only')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ | |
io.observe(child); | ||
} | ||
}; | ||
window.dispatchEvent(new Event('astro:visible')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.