Skip to content

Commit

Permalink
Clean up a few tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Oct 21, 2024
1 parent c34f9f7 commit 26c9be5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
8 changes: 7 additions & 1 deletion src/examples/tests/TestCls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
}
onMount(() => {
let animationFrameHandle: number;
(function tick() {
// Nesting measurements creates a hierarchy in the Profile visualization
measure('Tick', () => {
Expand All @@ -171,8 +173,12 @@
});
});
requestAnimationFrame(tick);
animationFrameHandle = requestAnimationFrame(tick);
})();
return () => {
cancelAnimationFrame(animationFrameHandle);
};
});
</script>

Expand Down
4 changes: 2 additions & 2 deletions src/examples/tests/TestColor.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
binding3ExternalEventCount++;
}
}}
label="Binding 1"
label="Binding 3"
/>
<Color
bind:value={value2}
Expand All @@ -56,7 +56,7 @@
binding4ExternalEventCount++;
}
}}
label="Binding 2"
label="Binding 4"
/>

<hr />
Expand Down
15 changes: 14 additions & 1 deletion src/examples/tests/TestStoreInitialization.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,28 @@
import { writable } from 'svelte/store';
const bear = writable({ apples: 100, name: 'Someone' });
const bear2 = writable({ apples: 100, name: 'Someone' });
onMount(async () => {
// No tick
$bear2.apples = 60;
// With Tick
await tick();
$bear.apples = 60;
});
</script>

<h1>With tick, works in Svelte 4</h1>

<p>Native input</p>
<input bind:value={$bear.apples} min={0} max={100} step={1} type="range" />
{$bear.apples}
<p>Svelte Tweakpane UI</p>
<Slider bind:value={$bear.apples} min={0} max={100} step={1} />

<h1>Without tick, works in Svelte 5</h1>

<p>Native input</p>
<input bind:value={$bear2.apples} min={0} max={100} step={1} type="range" />
<p>Svelte Tweakpane UI</p>
<Slider bind:value={$bear2.apples} min={0} max={100} step={1} />

0 comments on commit 26c9be5

Please sign in to comment.