mirror of https://github.com/sveltejs/svelte
commit
6d06d5aae1
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: better readonly checks for proxies
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: prevent infinite loops stemming from invalidation method
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: improve non state referenced warning
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: improve consistency issues around binding invalidation
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: adjust children snippet default type
|
||||||
@ -0,0 +1,32 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { ok, test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
html: `
|
||||||
|
<select>
|
||||||
|
<option value="a">A</option>
|
||||||
|
<option value="b">B</option>
|
||||||
|
</select>
|
||||||
|
selected: a
|
||||||
|
`,
|
||||||
|
|
||||||
|
test({ assert, target }) {
|
||||||
|
const select = target.querySelector('select');
|
||||||
|
ok(select);
|
||||||
|
const event = new window.Event('change');
|
||||||
|
select.value = 'b';
|
||||||
|
select.dispatchEvent(event);
|
||||||
|
flushSync();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<select>
|
||||||
|
<option value="a">A</option>
|
||||||
|
<option value="b">B</option>
|
||||||
|
</select>
|
||||||
|
selected: b
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<script>
|
||||||
|
let entries = [{selected: 'a' }]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each entries as entry}
|
||||||
|
<select bind:value={entry.selected}>
|
||||||
|
<option value='a'>A</option>
|
||||||
|
<option value='b'>B</option>
|
||||||
|
</select>
|
||||||
|
selected: {entry.selected}
|
||||||
|
{/each}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
assert.htmlEqual(target.innerHTML, 'a\n<select></select><button>change</button');
|
||||||
|
|
||||||
|
const [b1] = target.querySelectorAll('button');
|
||||||
|
b1.click();
|
||||||
|
await Promise.resolve();
|
||||||
|
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
'a\n<select></select>b\n<select></select><button>change</button'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
<script>
|
||||||
|
let entries = $state([{selected: 'a'}])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each entries as entry}
|
||||||
|
{entry.selected} <select bind:value={entry.selected}></select>
|
||||||
|
{/each}
|
||||||
|
|
||||||
|
<button
|
||||||
|
on:click={
|
||||||
|
() => entries = [{selected: 'a'}, {selected: 'b'}]
|
||||||
|
}
|
||||||
|
>change</button>
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
/** @type {{ object: { count: number }}} */
|
||||||
|
let { object } = $props();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => object = { count: object.count + 1 } }>
|
||||||
|
clicks: {object.count}
|
||||||
|
</button>
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
// Tests that readonly bails on setters/classes
|
||||||
|
export default test({
|
||||||
|
html: `<button>clicks: 0</button><button>clicks: 0</button>`,
|
||||||
|
|
||||||
|
compileOptions: {
|
||||||
|
dev: true
|
||||||
|
},
|
||||||
|
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const [btn1, btn2] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
await btn1.click();
|
||||||
|
await btn2.click();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<button>clicks: 1</button><button>clicks: 1</button>`);
|
||||||
|
|
||||||
|
await btn1.click();
|
||||||
|
await btn2.click();
|
||||||
|
assert.htmlEqual(target.innerHTML, `<button>clicks: 2</button><button>clicks: 2</button>`);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,25 @@
|
|||||||
|
<script>
|
||||||
|
import Counter from './Counter.svelte';
|
||||||
|
|
||||||
|
function createCounter() {
|
||||||
|
let count = $state(0)
|
||||||
|
return {
|
||||||
|
get count() {
|
||||||
|
return count;
|
||||||
|
},
|
||||||
|
set count(upd) {
|
||||||
|
count = upd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CounterClass {
|
||||||
|
count = $state(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const counterSetter = createCounter();
|
||||||
|
const counterClass = new CounterClass();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Counter object={counterSetter} />
|
||||||
|
<Counter object={counterClass} />
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({});
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
<script>
|
||||||
|
let a = $state({b: 0});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => a.b += 1}>a += 1</button>
|
||||||
|
<p>{JSON.stringify(a)} + {a.b}</p>
|
||||||
Loading…
Reference in new issue