-
-
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
Fix race condition with directive definitions #4375
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 and clean 👏
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.
()=>this.start() may be simply passed as this.start to make it cleaner