Merge branch '1.x' into 'dev'
This commit is contained in:
@@ -30,7 +30,15 @@ export default sfc({
|
||||
|
||||
methods: {
|
||||
toggle() {
|
||||
this.checked = !this.checked;
|
||||
const checked = !this.checked;
|
||||
|
||||
// When toggle method is called multiple times at the same time,
|
||||
// only the last call is valid.
|
||||
// This is a hack for usage inside Cell.
|
||||
clearTimeout(this.toggleTask);
|
||||
this.toggleTask = setTimeout(() => {
|
||||
this.checked = checked;
|
||||
});
|
||||
},
|
||||
|
||||
onClickIcon() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import Checkbox from '..';
|
||||
import CheckboxGroup from '../../checkbox-group';
|
||||
import { mount } from '../../../test/utils';
|
||||
import { mount, later } from '../../../test/utils';
|
||||
|
||||
test('switch checkbox', () => {
|
||||
test('switch checkbox', async () => {
|
||||
const wrapper = mount(Checkbox);
|
||||
|
||||
wrapper.vm.$on('input', value => {
|
||||
@@ -11,8 +11,9 @@ test('switch checkbox', () => {
|
||||
|
||||
const icon = wrapper.find('.van-checkbox__icon');
|
||||
icon.trigger('click');
|
||||
await later();
|
||||
icon.trigger('click');
|
||||
|
||||
await later();
|
||||
expect(wrapper.emitted('input')).toEqual([[true], [false]]);
|
||||
expect(wrapper.emitted('change')).toEqual([[true], [false]]);
|
||||
});
|
||||
@@ -42,7 +43,7 @@ test('label disabled', () => {
|
||||
expect(wrapper.emitted('input')).toBeFalsy();
|
||||
});
|
||||
|
||||
test('checkbox group', () => {
|
||||
test('checkbox group', async () => {
|
||||
const wrapper = mount({
|
||||
template: `
|
||||
<checkbox-group v-model="result" :max="2">
|
||||
@@ -63,11 +64,15 @@ test('checkbox group', () => {
|
||||
|
||||
const icons = wrapper.findAll('.van-checkbox__icon');
|
||||
icons.at(0).trigger('click');
|
||||
await later();
|
||||
icons.at(1).trigger('click');
|
||||
await later();
|
||||
icons.at(2).trigger('click');
|
||||
expect(wrapper.vm.result).toEqual(['a', 'b']);
|
||||
|
||||
await later();
|
||||
icons.at(0).trigger('click');
|
||||
await later();
|
||||
expect(wrapper.vm.result).toEqual(['b']);
|
||||
});
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ export const CheckboxMixin = (parent, bem) => ({
|
||||
<div
|
||||
class={bem()}
|
||||
onClick={event => {
|
||||
event.stopPropagation();
|
||||
this.$emit('click', event);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -144,7 +144,7 @@ export default sfc({
|
||||
const text = this[`${status}Text`] || t(status);
|
||||
const style = {
|
||||
transition: `${this.duration}ms`,
|
||||
transform: `translate3d(0,${this.height}px, 0)`
|
||||
transform: this.height ? `translate3d(0,${this.height}px, 0)` : ''
|
||||
};
|
||||
|
||||
const Status = this.slots(status) || [
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
exports[`renders demo correctly 1`] = `
|
||||
<div>
|
||||
<div class="van-pull-refresh">
|
||||
<div class="van-pull-refresh__track" style="transition:0ms;transform:translate3d(0,0px, 0);">
|
||||
<div class="van-pull-refresh__track" style="transition:0ms;transform:;">
|
||||
<div class="van-pull-refresh__head"></div>
|
||||
<div>
|
||||
<p>刷新次数: 0</p>
|
||||
|
||||
@@ -46,7 +46,7 @@ exports[`change head content when pulling down 4`] = `
|
||||
|
||||
exports[`change head content when pulling down 5`] = `
|
||||
<div class="van-pull-refresh">
|
||||
<div class="van-pull-refresh__track" style="transition: 300ms; transform: translate3d(0,0px, 0);">
|
||||
<div class="van-pull-refresh__track" style="transition: 300ms;">
|
||||
<div class="van-pull-refresh__head"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -54,7 +54,7 @@ exports[`change head content when pulling down 5`] = `
|
||||
|
||||
exports[`not in page top 1`] = `
|
||||
<div class="van-pull-refresh">
|
||||
<div class="van-pull-refresh__track" style="transition: 0ms; transform: translate3d(0,0px, 0);">
|
||||
<div class="van-pull-refresh__track" style="transition: 0ms;">
|
||||
<div class="van-pull-refresh__head"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user