mirror of https://github.com/sveltejs/svelte
commit
d1c2992acf
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't transform references of function declarations in legacy mode
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: notify deriveds of changes to sources inside forks
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: prevent derives without dependencies from ever re-running
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: correctly update writable deriveds inside forks
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: remove `$inspect` calls after await expressions when compiling for production server code
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: clear batch between runs
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: adjust `loc` property of `Program` nodes created from `<script>` elements
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: don't revert source to UNINITIALIZED state when time travelling
|
||||
@ -0,0 +1,24 @@
|
||||
import { tick } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
compileOptions: {
|
||||
dev: true
|
||||
},
|
||||
|
||||
async test({ assert, target }) {
|
||||
const [fork] = target.querySelectorAll('button');
|
||||
|
||||
fork.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '<button>fork</button><button>false</button>');
|
||||
|
||||
const [, toggle] = target.querySelectorAll('button');
|
||||
|
||||
toggle.click();
|
||||
await tick();
|
||||
|
||||
assert.htmlEqual(target.innerHTML, '<button>fork</button><button>true</button>');
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,26 @@
|
||||
<script>
|
||||
import { fork } from 'svelte';
|
||||
|
||||
let condition = $state(false);
|
||||
let checked = $state(false);
|
||||
|
||||
const d = $derived({ checked });
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
fork(() => {
|
||||
condition = true;
|
||||
}).commit();
|
||||
}}>fork</button>
|
||||
|
||||
{#if condition}
|
||||
<!-- in dev, snippet arguments are read eagerly, outside a tracking context -->
|
||||
<!-- this test checks that doing so doesn't prevent the derived from connecting -->
|
||||
{#snippet foo({ checked })}
|
||||
{checked}
|
||||
{/snippet}
|
||||
|
||||
<button onclick={() => (checked = !checked)}>
|
||||
{@render foo(d)}
|
||||
</button>
|
||||
{/if}
|
||||
@ -0,0 +1,47 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<button>+1</button>
|
||||
<button>add number</button>
|
||||
<p>1, 2, 3</p>
|
||||
`,
|
||||
|
||||
test({ assert, target }) {
|
||||
const [button1, button2] = target.querySelectorAll('button');
|
||||
|
||||
button1.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>+1</button>
|
||||
<button>add number</button>
|
||||
<p>2, 4, 6</p>
|
||||
`
|
||||
);
|
||||
|
||||
button2.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>+1</button>
|
||||
<button>add number</button>
|
||||
<p>2, 4, 6, 8</p>
|
||||
`
|
||||
);
|
||||
|
||||
button1.click();
|
||||
flushSync();
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>+1</button>
|
||||
<button>add number</button>
|
||||
<p>3, 6, 9, 12</p>
|
||||
`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,30 @@
|
||||
<script lang="ts">
|
||||
class Item {
|
||||
product: number;
|
||||
|
||||
constructor(n: number) {
|
||||
this.product = $derived(multiplier * n);
|
||||
}
|
||||
}
|
||||
|
||||
let numbers = $state([1, 2, 3]);
|
||||
let multiplier = $state(1);
|
||||
|
||||
let items = $derived(numbers.map((n) => new Item(n)))
|
||||
let products = $derived(items.map(item => item.product));
|
||||
</script>
|
||||
|
||||
<button onclick={() => {
|
||||
multiplier += 1;
|
||||
}}>+1</button>
|
||||
|
||||
<button onclick={() => {
|
||||
numbers.push(numbers.length + 1);
|
||||
|
||||
// this is load-bearing — by reading it outside a reaction, we recompute
|
||||
// `products`, removing it as a reaction from `Item.product` dependencies,
|
||||
// but we don't add it as a reaction to the new `Item.product` dependencies
|
||||
products;
|
||||
}}>add number</button>
|
||||
|
||||
<p>{products.join(', ')}</p>
|
||||
Loading…
Reference in new issue