File tree Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Expand file tree Collapse file tree 3 files changed +22
-3
lines changed Original file line number Diff line number Diff line change 35
35
@focus =" focus = true"
36
36
@blur =" focus = false" >
37
37
38
- <span class =" el-checkbox-button__inner"
38
+ <span class =" el-checkbox-button__inner"
39
39
v-if =" $slots.default || label"
40
40
:style =" isChecked ? activeStyle : null" >
41
41
<slot >{{label}}</slot >
150
150
return this ._checkboxGroup .checkboxGroupSize || this ._elFormItemSize || (this .$ELEMENT || {}).size ;
151
151
},
152
152
153
+ /* used to make the isDisabled judgment under max/min props */
154
+ isLimitDisabled () {
155
+ const { max , min } = this ._checkboxGroup ;
156
+ return !! (max || min) &&
157
+ (this .model .length >= max && ! this .isChecked ) ||
158
+ (this .model .length <= min && this .isChecked );
159
+ },
160
+
153
161
isDisabled () {
154
162
return this ._checkboxGroup
155
- ? this ._checkboxGroup .disabled || this .disabled || (this .elForm || {}).disabled
163
+ ? this ._checkboxGroup .disabled || this .disabled || (this .elForm || {}).disabled || this . isLimitDisabled
156
164
: this .disabled || (this .elForm || {}).disabled ;
157
165
}
158
166
},
Original file line number Diff line number Diff line change 136
136
return this ._checkboxGroup ? this ._checkboxGroup .value : this .value ;
137
137
},
138
138
139
+ /* used to make the isDisabled judgment under max/min props */
140
+ isLimitDisabled () {
141
+ const { max , min } = this ._checkboxGroup ;
142
+ return !! (max || min) &&
143
+ (this .model .length >= max && ! this .isChecked ) ||
144
+ (this .model .length <= min && this .isChecked );
145
+ },
146
+
139
147
isDisabled () {
140
148
return this .isGroup
141
- ? this ._checkboxGroup .disabled || this .disabled || (this .elForm || {}).disabled
149
+ ? this ._checkboxGroup .disabled || this .disabled || (this .elForm || {}).disabled || this . isLimitDisabled
142
150
: this .disabled || (this .elForm || {}).disabled ;
143
151
},
144
152
Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ describe('Checkbox', () => {
147
147
}
148
148
} , true ) ;
149
149
expect ( vm . checkList . length === 1 ) . to . be . true ;
150
+ expect ( vm . $refs . a . isDisabled ) . to . be . true ;
150
151
vm . $refs . a . $el . click ( ) ;
151
152
vm . $nextTick ( ( ) => {
152
153
expect ( vm . checkList . indexOf ( 'a' ) !== - 1 ) . to . be . true ;
@@ -158,6 +159,8 @@ describe('Checkbox', () => {
158
159
vm . $nextTick ( ( ) => {
159
160
expect ( vm . checkList . indexOf ( 'c' ) !== - 1 ) . to . be . false ;
160
161
expect ( vm . checkList . indexOf ( 'd' ) !== - 1 ) . to . be . false ;
162
+ expect ( vm . $refs . c . isDisabled ) . to . be . true ;
163
+ expect ( vm . $refs . d . isDisabled ) . to . be . true ;
161
164
done ( ) ;
162
165
} ) ;
163
166
} ) ;
You can’t perform that action at this time.
0 commit comments