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/test/runtime/samples/component-binding-infinite-.../C.html

24 lines
441 B

<span
on:click="toggle()"
class="{isCurrentlySelected ? 'selected' : ''}"
>
<slot></slot>
</span>
<script>
export default {
computed: {
isCurrentlySelected: ({ currentIdentifier, identifier }) => currentIdentifier === identifier
},
methods: {
toggle() {
const isCurrentlySelected = this.get().isCurrentlySelected
this.set({
currentIdentifier: isCurrentlySelected ? null : this.get().identifier
})
}
}
}
</script>