mirror of https://github.com/sveltejs/svelte
commit
471f479305
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: invalidate parent effects when child effects update parent dependencies
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: correctly match `:has()` selector during css pruning
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: replace `undefined` with `void 0` to avoid edge case
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: allow global-like pseudo-selectors refinement
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
chore: don't distribute unused types definitions
|
||||
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: ensure clearing of old values happens independent of root flushes
|
||||
@ -1,5 +0,0 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
fix: add `files` and `group` to HTMLInputAttributes in elements.d.ts
|
||||
@ -1,8 +0,0 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'constant_assignment',
|
||||
message: 'Cannot assign to derived state'
|
||||
}
|
||||
});
|
||||
@ -1,5 +0,0 @@
|
||||
<script>
|
||||
const a = $state(0);
|
||||
let b = $derived(a);
|
||||
b = 1;
|
||||
</script>
|
||||
@ -1,8 +0,0 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'constant_binding',
|
||||
message: 'Cannot bind to derived state'
|
||||
}
|
||||
});
|
||||
@ -1,6 +0,0 @@
|
||||
<script>
|
||||
let a = $state(0);
|
||||
let b = $derived({ a });
|
||||
</script>
|
||||
|
||||
<input type="number" bind:value={b} />
|
||||
@ -1,8 +0,0 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'constant_assignment',
|
||||
message: 'Cannot assign to derived state'
|
||||
}
|
||||
});
|
||||
@ -1,10 +0,0 @@
|
||||
<script>
|
||||
class Counter {
|
||||
count = $state();
|
||||
#doubled = $derived(this.count * 2);
|
||||
|
||||
nope() {
|
||||
this.#doubled += 1;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1,8 +0,0 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'constant_assignment',
|
||||
message: 'Cannot assign to derived state'
|
||||
}
|
||||
});
|
||||
@ -1,10 +0,0 @@
|
||||
<script>
|
||||
class Counter {
|
||||
count = $state();
|
||||
#doubled = $derived(this.count * 2);
|
||||
|
||||
nope() {
|
||||
this.#doubled++;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@ -1,8 +0,0 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'constant_assignment',
|
||||
message: 'Cannot assign to derived state'
|
||||
}
|
||||
});
|
||||
@ -1,5 +0,0 @@
|
||||
<script>
|
||||
const a = $state(0);
|
||||
let b = $derived(a);
|
||||
b++;
|
||||
</script>
|
||||
@ -0,0 +1,8 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
error: {
|
||||
code: 'rune_invalid_arguments_length',
|
||||
message: '`$state.raw` must be called with zero or one arguments'
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,3 @@
|
||||
<script>
|
||||
const foo = $state.raw(1, 2, 3);
|
||||
</script>
|
||||
@ -0,0 +1 @@
|
||||
const foo = $state.raw(1, 2, 3);
|
||||
@ -0,0 +1,5 @@
|
||||
<script>
|
||||
let { foo } = $props();
|
||||
</script>
|
||||
|
||||
{@render foo()}
|
||||
@ -0,0 +1,20 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
warnings: [
|
||||
{
|
||||
code: 'css_unused_selector',
|
||||
message: 'Unused CSS selector "n + m"',
|
||||
end: {
|
||||
character: 468,
|
||||
column: 6,
|
||||
line: 36
|
||||
},
|
||||
start: {
|
||||
character: 463,
|
||||
column: 1,
|
||||
line: 36
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@ -0,0 +1,8 @@
|
||||
x.svelte-xyz + y:where(.svelte-xyz) { color: green; }
|
||||
x.svelte-xyz + v:where(.svelte-xyz) { color: green; }
|
||||
x.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||
y.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||
v.svelte-xyz + z:where(.svelte-xyz) { color: green; }
|
||||
.component + z.svelte-xyz { color: green; }
|
||||
|
||||
/* (unused) n + m { color: red; }*/
|
||||
@ -0,0 +1,37 @@
|
||||
<script>
|
||||
import Child from './Child.svelte';
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<x></x>
|
||||
<Child>
|
||||
<y></y>
|
||||
{#snippet foo()}
|
||||
<v></v>
|
||||
{/snippet}
|
||||
</Child>
|
||||
<z></z>
|
||||
|
||||
<Child>
|
||||
<span>
|
||||
<n></n>
|
||||
</span>
|
||||
{#snippet foo()}
|
||||
<span>
|
||||
<n></n>
|
||||
</span>
|
||||
{/snippet}
|
||||
</Child>
|
||||
<m></m>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
x + y { color: green; }
|
||||
x + v { color: green; }
|
||||
x + z { color: green; }
|
||||
y + z { color: green; }
|
||||
v + z { color: green; }
|
||||
:global(.component) + z { color: green; }
|
||||
|
||||
n + m { color: red; }
|
||||
</style>
|
||||
@ -1 +1,2 @@
|
||||
<p class="svelte-xyz">Foo</p>
|
||||
<p class="svelte-xyz">Foo</p>
|
||||
<p class="svelte-xyz">Bar</p>
|
||||
@ -1,3 +1,4 @@
|
||||
<style>p { color: red; }</style>
|
||||
|
||||
<p class={undefined}>Foo</p>
|
||||
<p class={undefined}>Foo</p>
|
||||
<p class="{undefined}">Bar</p>
|
||||
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
let name = 'world';
|
||||
|
||||
$: upper = name.toUpperCase();
|
||||
</script>
|
||||
|
||||
<input bind:value={name} />
|
||||
<input bind:value={upper} />
|
||||
|
||||
{upper}
|
||||
@ -0,0 +1,10 @@
|
||||
<script>
|
||||
let name = $state('world');
|
||||
|
||||
let upper = $derived(name.toUpperCase());
|
||||
</script>
|
||||
|
||||
<input bind:value={name} />
|
||||
<input bind:value={upper} />
|
||||
|
||||
{upper}
|
||||
@ -0,0 +1,5 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `<p>state,derived state,derived.by derived state</p>`
|
||||
});
|
||||
@ -0,0 +1,18 @@
|
||||
<script>
|
||||
class Foo {
|
||||
#state = $state('state')
|
||||
#derived = $derived('derived ' + this.#state);
|
||||
#derivedBy = $derived.by(() => {
|
||||
return 'derived.by ' + this.#derived
|
||||
});
|
||||
|
||||
initial
|
||||
|
||||
constructor() {
|
||||
this.initial = [this.#state, this.#derived, this.#derivedBy]
|
||||
}
|
||||
}
|
||||
const foo = new Foo()
|
||||
</script>
|
||||
|
||||
<p>{foo.initial}</p>
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
|
||||
let thing = $state(0)
|
||||
|
||||
onMount(() => {
|
||||
thing = 1;
|
||||
return () => {
|
||||
console.log(thing);
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@ -0,0 +1,7 @@
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, logs }) {
|
||||
assert.deepEqual(logs, [1]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,14 @@
|
||||
<script>
|
||||
import { onMount } from "svelte"
|
||||
import Component from './Component.svelte';
|
||||
|
||||
let key = $state(0);
|
||||
|
||||
onMount(() => {
|
||||
key = 1;
|
||||
})
|
||||
</script>
|
||||
|
||||
{#key key}
|
||||
<Component />
|
||||
{/key}
|
||||
@ -0,0 +1,16 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target }) {
|
||||
let btn = target.querySelector('button');
|
||||
|
||||
btn?.click();
|
||||
flushSync();
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<div>Count 1!</div><div>Count from store 1!</div><button>Add 1</button>`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,11 @@
|
||||
<script>
|
||||
import { toStore } from "svelte/store";
|
||||
|
||||
let counter = $state(0);
|
||||
const count = toStore(() => counter, value => counter = value);
|
||||
</script>
|
||||
|
||||
<div>Count {counter}!</div>
|
||||
<div>Count from store {$count}!</div>
|
||||
|
||||
<button onclick={() => counter+=1}>Add 1</button>
|
||||
@ -0,0 +1,12 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, errors }) {
|
||||
const button = target.querySelector('button');
|
||||
flushSync(() => {
|
||||
button?.click();
|
||||
});
|
||||
assert.deepEqual(errors, []);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,12 @@
|
||||
<script>
|
||||
const log = () => {
|
||||
console.log(snip);
|
||||
}
|
||||
let x = $state(0);
|
||||
</script>
|
||||
|
||||
<button onclick={log}></button>
|
||||
|
||||
{#snippet snip()}
|
||||
snippet {x}
|
||||
{/snippet}
|
||||
@ -0,0 +1,20 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
test({ assert, target, logs }) {
|
||||
const button = target.querySelector('button');
|
||||
|
||||
flushSync(() => button?.click());
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`
|
||||
<button>increment</button>
|
||||
<p>1/2</p
|
||||
`
|
||||
);
|
||||
|
||||
assert.deepEqual(logs, [0, 0]);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,26 @@
|
||||
<script>
|
||||
class Foo {
|
||||
value = $state(0);
|
||||
double = $derived(this.value * 2);
|
||||
|
||||
constructor() {
|
||||
console.log(this.value, this.double);
|
||||
}
|
||||
|
||||
increment() {
|
||||
this.value++;
|
||||
}
|
||||
}
|
||||
|
||||
let foo = $state();
|
||||
|
||||
$effect(() => {
|
||||
foo = new Foo();
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={() => foo.increment()}>increment</button>
|
||||
|
||||
{#if foo}
|
||||
<p>{foo.value}/{foo.double}</p>
|
||||
{/if}
|
||||
@ -0,0 +1,46 @@
|
||||
import { flushSync } from 'svelte';
|
||||
import { test } from '../../test';
|
||||
|
||||
export default test({
|
||||
html: `
|
||||
<input type="range"><input type="range"><p>0 * 2 = 0</p>
|
||||
`,
|
||||
|
||||
ssrHtml: `
|
||||
<input type="range" value="0"><input type="range" value="0"><p>0 * 2 = 0</p>
|
||||
`,
|
||||
|
||||
test({ assert, target, window }) {
|
||||
const [input1, input2] = target.querySelectorAll('input');
|
||||
|
||||
flushSync(() => {
|
||||
input1.value = '10';
|
||||
input1.dispatchEvent(new window.Event('input', { bubbles: true }));
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<input type="range"><input type="range"><p>10 * 2 = 20</p>`
|
||||
);
|
||||
|
||||
flushSync(() => {
|
||||
input2.value = '99';
|
||||
input2.dispatchEvent(new window.Event('input', { bubbles: true }));
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<input type="range"><input type="range"><p>10 * 2 = 99</p>`
|
||||
);
|
||||
|
||||
flushSync(() => {
|
||||
input1.value = '20';
|
||||
input1.dispatchEvent(new window.Event('input', { bubbles: true }));
|
||||
});
|
||||
|
||||
assert.htmlEqual(
|
||||
target.innerHTML,
|
||||
`<input type="range"><input type="range"><p>20 * 2 = 40</p>`
|
||||
);
|
||||
}
|
||||
});
|
||||
@ -0,0 +1,9 @@
|
||||
<script>
|
||||
let count = $state(0);
|
||||
let double = $derived(count * 2);
|
||||
</script>
|
||||
|
||||
<input type="range" bind:value={count} />
|
||||
<input type="range" bind:value={double} />
|
||||
|
||||
<p>{count} * 2 = {double}</p>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue