12
12
@MDCIconButtonToggle:change =" $emit('change', $event.detail.isOn)" >
13
13
<slot v-if =" isIconButton" />
14
14
<slot
15
- v-else- if =" isToggleButtonViaSlots && !value"
15
+ v-if =" isToggleButtonViaSlots && !value"
16
16
name =" toggleOn" />
17
17
<slot
18
- v-else- if =" isToggleButtonViaSlots && value"
18
+ v-if =" isToggleButtonViaSlots && value"
19
19
name =" toggleOff" />
20
20
</button >
21
21
</template >
@@ -69,6 +69,17 @@ export default {
69
69
slotObserver: undefined
70
70
}
71
71
},
72
+ computed: {
73
+ isToggleButtonViaSlots () {
74
+ return this .$slots .toggleOn && this .$slots .toggleOff && ! this .isIconButton
75
+ },
76
+ isIconButton () {
77
+ return this .$slots .default
78
+ },
79
+ isToggleButton () {
80
+ return this .toggleOnContent !== ' ' && this .toggleOffContent !== ' '
81
+ }
82
+ },
72
83
watch: {
73
84
value (value ) {
74
85
if (typeof this .mdcIconButtonToggle !== ' undefined' ) {
@@ -94,26 +105,14 @@ export default {
94
105
},
95
106
methods: {
96
107
update () {
97
- if ((this .isToggleButton () || this .isToggleButtonViaSlots () ) && typeof this .mdcIconButtonToggle === ' undefined' ) {
108
+ if ((this .isToggleButton || this .isToggleButtonViaSlots ) && typeof this .mdcIconButtonToggle === ' undefined' ) {
98
109
this .mdcIconButtonToggle = MDCIconButtonToggle .attachTo (this .$el )
99
110
this .mdcIconButtonToggle .on = this .value
100
111
}
101
- if (this .isIconButton () && typeof this .mdcRipple === ' undefined' ) {
112
+ if (this .isIconButton && typeof this .mdcRipple === ' undefined' ) {
102
113
this .mdcRipple = MDCRipple .attachTo (this .$el )
103
114
this .mdcRipple .unbounded = true
104
115
}
105
- },
106
- isIconButton () {
107
- return this .$slots .default
108
- },
109
- isToggleButton () {
110
- return this .toggleOnContent !== ' ' && this .toggleOffContent !== ' '
111
- },
112
- isToggleButtonViaSlots () {
113
- return this .toggleOnContent === ' ' &&
114
- this .toggleOffContent === ' ' &&
115
- this .$slots .toggleOn &&
116
- this .$slots .toggleOff
117
116
}
118
117
}
119
118
}
0 commit comments