-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure HMR doesn't mess with anchor nodes
The refactoring in #12215 didn't take HMR into account. As a result, the anchor was passed to the HMR block, which was subsequently cleaned up on destroy - but the anchor could be shared with other components and therefore needs to stay in the dom. Passing `null` instead solves the problem. Fixes #12228
- Loading branch information
1 parent
434e1ad
commit aa1720c
Showing
6 changed files
with
34 additions
and
1 deletion.
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 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure HMR doesn't mess with anchor nodes |
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
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/runtime-runes/samples/svelte-component-switch-dev/A.svelte
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 @@ | ||
A |
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/runtime-runes/samples/svelte-component-switch-dev/B.svelte
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 @@ | ||
B |
17 changes: 17 additions & 0 deletions
17
packages/svelte/tests/runtime-runes/samples/svelte-component-switch-dev/_config.js
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,17 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
mode: ['client'], | ||
compileOptions: { | ||
hmr: true, | ||
dev: true | ||
}, | ||
test({ target, assert }) { | ||
assert.htmlEqual(target.innerHTML, `<button>switch</button> A`); | ||
|
||
target.querySelector('button')?.click(); | ||
flushSync(); | ||
assert.htmlEqual(target.innerHTML, `<button>switch</button> B`); | ||
} | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/svelte/tests/runtime-runes/samples/svelte-component-switch-dev/main.svelte
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 @@ | ||
<script> | ||
import A from './A.svelte'; | ||
import B from './B.svelte'; | ||
let component = $state(A); | ||
</script> | ||
|
||
<button onclick={() => (component = B)}>switch</button> | ||
<svelte:component this={component} /> |