mirror of https://github.com/sveltejs/svelte
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.
24 lines
437 B
24 lines
437 B
8 years ago
|
<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>
|