mirror of https://github.com/sveltejs/svelte
fix: cache call expressions in render tag arguments (#12418)
* fix: cache call expressions in render tag arguments Ensure that they're called at most once per change, not once per access within the snippet fixes #12187 * leverage state * types * fixpull/12408/head
parent
d967780c4f
commit
70cec4e40e
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: cache call expressions in render tag arguments
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
test({ assert, logs }) {
|
||||||
|
assert.deepEqual(logs, ['invoked']);
|
||||||
|
},
|
||||||
|
test_ssr({ assert, logs }) {
|
||||||
|
assert.deepEqual(logs, ['invoked']);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,13 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
let el = $state({ foo: 'foo', bar: 'bar' });
|
||||||
|
function fn(el) {
|
||||||
|
console.log('invoked')
|
||||||
|
return el;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#snippet foo(a)}
|
||||||
|
{a.foo} {a.bar}
|
||||||
|
{/snippet}
|
||||||
|
|
||||||
|
{@render foo(fn(el))}
|
Loading…
Reference in new issue