mirror of https://github.com/sveltejs/svelte
parent
79e7203c3b
commit
05636d309b
@ -0,0 +1,15 @@
|
||||
<script>
|
||||
let { message, count } = $props();
|
||||
|
||||
$effect(() => () => {
|
||||
console.log(count, message);
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>{count}</p>
|
||||
|
||||
<!-- we need these so that the props are made into deriveds -->
|
||||
<button disabled onclick={() => {
|
||||
count += 1;
|
||||
message += '!';
|
||||
}}>update</button>
|
@ -0,0 +1,17 @@
|
||||
import { test } from '../../test';
|
||||
import { flushSync } from 'svelte';
|
||||
|
||||
export default test({
|
||||
async test({ assert, target, logs }) {
|
||||
const [increment, toggle] = target.querySelectorAll('button');
|
||||
|
||||
flushSync(() => toggle.click());
|
||||
assert.deepEqual(logs, [0, 'hello']);
|
||||
|
||||
flushSync(() => toggle.click());
|
||||
flushSync(() => increment.click());
|
||||
flushSync(() => increment.click());
|
||||
|
||||
assert.deepEqual(logs, [0, 'hello', 1, 'hello']);
|
||||
}
|
||||
});
|
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import Component from "./Component.svelte";
|
||||
|
||||
let message = $state('hello');
|
||||
let count = $state(0);
|
||||
</script>
|
||||
|
||||
<button onclick={() => count++}>{count}</button>
|
||||
<button onclick={() => message = message === 'hello' ? 'goodbye' : 'hello'}>{message}</button>
|
||||
|
||||
{#if count < 2 && message === 'hello'}
|
||||
<Component {count} {message} />
|
||||
{/if}
|
Loading…
Reference in new issue