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
437 B

<span
on:click="toggle()"
class="{{isCurrentlySelected ? 'selected' : ''}}"
>
{{yield}}
</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>