-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure components always return an object (#12290)
Closes #12287 --------- Co-authored-by: Simon H <[email protected]> Co-authored-by: Simon Holthausen <[email protected]>
- Loading branch information
1 parent
831552f
commit e42bb61
Showing
15 changed files
with
74 additions
and
0 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 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: ensure component always returns an object |
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
5 changes: 5 additions & 0 deletions
5
packages/svelte/tests/runtime-runes/samples/bind-this-frozen/ComponentA.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,5 @@ | ||
<script> | ||
export const a = {}; | ||
</script> | ||
|
||
<div>a</div> |
1 change: 1 addition & 0 deletions
1
packages/svelte/tests/runtime-runes/samples/bind-this-frozen/ComponentB.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 @@ | ||
<div>b</div> |
26 changes: 26 additions & 0 deletions
26
packages/svelte/tests/runtime-runes/samples/bind-this-frozen/_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,26 @@ | ||
import { flushSync } from 'svelte'; | ||
import { test } from '../../test'; | ||
|
||
export default test({ | ||
html: `<button>a</button><button>b</button><div>a</div>`, | ||
compileOptions: { | ||
dev: false | ||
}, | ||
|
||
async test({ assert, target, logs, ok }) { | ||
const [btn1, btn2] = target.querySelectorAll('button'); | ||
|
||
flushSync(() => { | ||
btn2.click(); | ||
}); | ||
|
||
assert.htmlEqual(target.innerHTML, `<button>a</button><button>b</button><div>b</div>`); | ||
|
||
flushSync(() => { | ||
btn1.click(); | ||
}); | ||
|
||
assert.htmlEqual(target.innerHTML, `<button>a</button><button>b</button><div>a</div>`); | ||
assert.deepEqual(logs, [{ a: {} }, {}, { a: {} }]); | ||
} | ||
}); |
24 changes: 24 additions & 0 deletions
24
packages/svelte/tests/runtime-runes/samples/bind-this-frozen/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,24 @@ | ||
<script> | ||
import ComponentA from './ComponentA.svelte'; | ||
import ComponentB from './ComponentB.svelte'; | ||
let type = $state(ComponentA); | ||
let elem = $state.frozen(); | ||
$effect(() => { | ||
console.log(elem); | ||
}); | ||
</script> | ||
|
||
<button | ||
onclick={() => { | ||
type = ComponentA; | ||
}}>a</button | ||
> | ||
<button | ||
onclick={() => { | ||
type = ComponentB; | ||
}}>b</button | ||
> | ||
|
||
<svelte:component this={type} bind:this={elem}>Content</svelte:component> |
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
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
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 |
---|---|---|
|
@@ -30,4 +30,5 @@ export default function Main($$anchor) { | |
}); | ||
|
||
$.append($$anchor, fragment); | ||
return {}; | ||
} |
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 |
---|---|---|
|
@@ -13,4 +13,5 @@ export default function Each_string_template($$anchor) { | |
}); | ||
|
||
$.append($$anchor, fragment); | ||
return {}; | ||
} |
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 |
---|---|---|
|
@@ -22,4 +22,6 @@ export default function Function_prop_no_getter($$anchor) { | |
}, | ||
$$slots: { default: true } | ||
}); | ||
|
||
return {}; | ||
} |
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,4 +7,5 @@ export default function Hello_world($$anchor) { | |
var h1 = root(); | ||
|
||
$.append($$anchor, h1); | ||
return {}; | ||
} |
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,6 +7,7 @@ function Hmr($$anchor) { | |
var h1 = root(); | ||
|
||
$.append($$anchor, h1); | ||
return {}; | ||
} | ||
|
||
if (import.meta.hot) { | ||
|
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
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