mirror of https://github.com/sveltejs/svelte
fix: don't eagerly access not-yet-initialized functions in template (#17938)
Our "hey this is a thunk invoking a function, let's flatten that" logic caused a bug where lazily-initialized functions where eagerly referenced in the template effect. That causes a nullpointer. Ensuring these variables are always referenced in a closure fixes #17404 --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>pull/17936/head
parent
b472171de6
commit
32a48ed174
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't eagerly access not-yet-initialized functions in template
|
||||
@ -0,0 +1,9 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
await tick();
|
||||
assert.htmlEqual(target.innerHTML, 'aaa 1');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
let name = $derived(await new Promise((a) => a('aaa')));
|
||||
function use() {
|
||||
return () => 1;
|
||||
}
|
||||
const aa = use();
|
||||
</script>
|
||||
|
||||
{name}
|
||||
{aa()}
|
||||
Loading…
Reference in new issue