You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/site/content/examples/21-miscellaneous/02-immutable-data/ImmutableTodo.svelte

29 lines
425 B

<svelte:options immutable/>
<script>
import { afterUpdate } from 'svelte';
import flash from './flash.js';
export let todo;
export let toggle;
let div;
afterUpdate(() => {
flash(div);
});
</script>
<style>
div {
cursor: pointer;
line-height: 1.5;
}
</style>
<!-- the text will flash red whenever
the `todo` object changes -->
<div bind:this={div} on:click>
{todo.done ? '👍': ''} {todo.text}
</div>