mirror of https://github.com/sveltejs/svelte
fix: ensure head effects are kept in the effect tree (#17746)
Fixes #17726 The problem was that the head effect had no "keep me around"-flag, which it needs because its children are not guaranteed to be present immediately - as shown in the related issue, where the child effect is only created once async work has completed. ### Before submitting the PR, please make sure you do the following - [x] It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs - [x] Prefix your PR title with `feat:`, `fix:`, `chore:`, or `docs:`. - [x] This message body should clearly illustrate what problems it solves. - [x] Ideally, include a test that fails without this PR but passes with it. - [x] If this PR changes code within `packages/svelte/src`, add a changeset (`npx changeset`). ### Tests and linting - [x] Run the tests with `pnpm test` and lint the project with `pnpm lint`pull/17747/head
parent
f8bf9bb461
commit
582e4443dc
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure head effects are kept in the effect tree
|
||||
@ -0,0 +1,12 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
|
||||
const p = target.querySelector('p');
|
||||
assert.equal(p?.innerHTML, 'hello');
|
||||
assert.equal(window.document.title, 'hello');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
let promise = Promise.resolve('hello');
|
||||
const value = $derived(await promise);
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>{value}</title>
|
||||
</svelte:head>
|
||||
|
||||
<p>{value}</p>
|
||||
Loading…
Reference in new issue