mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Switch: incorrect activeColor when use activeValue
This commit is contained in:
parent
094380416e
commit
172ed6eaee
@ -35,10 +35,10 @@ function Switch(
|
|||||||
|
|
||||||
const switchStyle = {
|
const switchStyle = {
|
||||||
fontSize: size,
|
fontSize: size,
|
||||||
backgroundColor: value ? activeColor : inactiveColor
|
backgroundColor: checked ? activeColor : inactiveColor
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadingColor = value ? activeColor || BLUE : inactiveColor || GRAY_DARK;
|
const loadingColor = checked ? activeColor || BLUE : inactiveColor || GRAY_DARK;
|
||||||
|
|
||||||
function onClick() {
|
function onClick() {
|
||||||
if (!disabled && !loading) {
|
if (!disabled && !loading) {
|
||||||
|
7
packages/switch/test/__snapshots__/index.spec.js.snap
Normal file
7
packages/switch/test/__snapshots__/index.spec.js.snap
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`inactive-color prop 1`] = `
|
||||||
|
<div role="switch" aria-checked="false" class="van-switch" style="font-size: 30px; background-color: black;">
|
||||||
|
<div class="van-switch__node"></div>
|
||||||
|
</div>
|
||||||
|
`;
|
@ -60,3 +60,15 @@ test('active-value & inactive-value prop', () => {
|
|||||||
expect(input).toHaveBeenCalledWith('2');
|
expect(input).toHaveBeenCalledWith('2');
|
||||||
expect(change).toHaveBeenCalledWith('2');
|
expect(change).toHaveBeenCalledWith('2');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('inactive-color prop', () => {
|
||||||
|
const wrapper = mount(Switch, {
|
||||||
|
propsData: {
|
||||||
|
value: '2',
|
||||||
|
inactiveValue: '2',
|
||||||
|
inactiveColor: 'black'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user