mirror of https://github.com/sveltejs/svelte
commit
7c5b06657c
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: include wrapping parentheses in `{@const}` declarator `end` position
|
|
||||||
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: don't notify `searchParams` subscribers when the URL changes without affecting the search string
|
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
import { tick } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
mode: ['client'],
|
||||||
|
|
||||||
|
compileOptions: {
|
||||||
|
dev: true
|
||||||
|
},
|
||||||
|
|
||||||
|
async test({ assert, target, errors }) {
|
||||||
|
await tick();
|
||||||
|
const [increment, update, resolve] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
increment.click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
resolve.click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
update.click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
resolve.click();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
errors.filter((error) => error.includes('state_unsafe_mutation')),
|
||||||
|
[]
|
||||||
|
);
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>increment</button>
|
||||||
|
<button>update</button>
|
||||||
|
<button>resolve</button>
|
||||||
|
<p>count: 1</p>
|
||||||
|
<p>submits: 1</p>
|
||||||
|
<p>pending: 0</p>
|
||||||
|
<p>2</p>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,28 @@
|
|||||||
|
<script>
|
||||||
|
const queued = [];
|
||||||
|
|
||||||
|
function push(value) {
|
||||||
|
if(!value) return value;
|
||||||
|
return new Promise((resolve) => queued.push(() => resolve(value)));
|
||||||
|
}
|
||||||
|
|
||||||
|
let count = $state(0);
|
||||||
|
let submits = $state(0);
|
||||||
|
|
||||||
|
const a = $derived(push(count));
|
||||||
|
const b = $derived(push(count));
|
||||||
|
|
||||||
|
async function updateAfterPromise() {
|
||||||
|
await Promise.resolve();
|
||||||
|
submits += 1;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => (count += 1)}>increment</button>
|
||||||
|
<button onclick={updateAfterPromise}>update</button>
|
||||||
|
<button onclick={() => queued.shift()?.()}>resolve</button>
|
||||||
|
|
||||||
|
<p>count: {count}</p>
|
||||||
|
<p>submits: {submits}</p>
|
||||||
|
<p>pending: {$effect.pending()}</p>
|
||||||
|
<p>{await a + await b}</p>
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
import 'svelte/internal/disclose-version';
|
||||||
|
import 'svelte/internal/flags/legacy';
|
||||||
|
import * as $ from 'svelte/internal/client';
|
||||||
|
|
||||||
|
export default function Typescript_optional_parameter($$anchor) {
|
||||||
|
// the `?` on the optional parameter must be stripped, but optional chaining
|
||||||
|
// (`x?.length`, `o?.b`) must be preserved
|
||||||
|
function a(x) {
|
||||||
|
return x?.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const o = {};
|
||||||
|
const v = o?.b?.c;
|
||||||
|
|
||||||
|
a();
|
||||||
|
$.next();
|
||||||
|
|
||||||
|
var text = $.text();
|
||||||
|
|
||||||
|
$.template_effect(() => $.set_text(text, v));
|
||||||
|
$.append($$anchor, text);
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
import * as $ from 'svelte/internal/server';
|
||||||
|
|
||||||
|
export default function Typescript_optional_parameter($$renderer) {
|
||||||
|
// the `?` on the optional parameter must be stripped, but optional chaining
|
||||||
|
// (`x?.length`, `o?.b`) must be preserved
|
||||||
|
function a(x) {
|
||||||
|
return x?.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const o = {};
|
||||||
|
const v = o?.b?.c;
|
||||||
|
|
||||||
|
a();
|
||||||
|
$$renderer.push(`<!---->${$.escape(v)}`);
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
// the `?` on the optional parameter must be stripped, but optional chaining
|
||||||
|
// (`x?.length`, `o?.b`) must be preserved
|
||||||
|
function a(x?: string) {
|
||||||
|
return x?.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
const o: { b?: { c: number } } = {};
|
||||||
|
const v = o?.b?.c;
|
||||||
|
|
||||||
|
a();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{v}
|
||||||
Loading…
Reference in new issue