Merge branch '1.x' into 'dev'

This commit is contained in:
陈嘉涵 2019-05-07 20:32:32 +08:00
commit 788ff0fe89
9 changed files with 51 additions and 12 deletions

View File

@ -15,6 +15,32 @@
- 当新增组件或者修改原有组件时,记得增加或者修改测试代码,保证代码的稳定
- 在 PR 中请添加合适的描述,并关联相关的 Issue
### Pull Request 流程
1. fork 主仓库,如果已经 fork 过,请同步主仓库的最新代码
2. 基于 fork 后仓库的 dev 分支新建一个分支,比如`feature/button_color`
3. 在新分支上进行开发,开发完成后,提 Pull Request 到主仓库的 dev 分支
4. Pull Request 会在 Review 通过后被合并到主仓库
5. 等待 Vant 发布版本,一般是每周一次
### 同步教程
提 Pull Request 前,请依照下面的流程同步主仓库的最新代码
```bash
# 添加主仓库到 remote作为 fork 后仓库的上游仓库
git remote add upstream https://github.com/youzan/vant.git
# 拉取主仓库最新代码
git fetch upstream
# 切换至 dev 分支
git checkout dev
# 合并主仓库代码
git merge upstream/dev
```
### 初始化项目
```bash

View File

@ -57,7 +57,8 @@
"@babel/runtime": "^7.4.4",
"@vant/icons": "1.1.7",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.3",
"vue-lazyload": "1.2.3"
"vue-lazyload": "1.2.3",
"webpack-dev-server": "^3.3.1"
},
"peerDependencies": {
"vue": ">= 2.5.0"

View File

@ -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() {

View File

@ -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']);
});

View File

@ -56,7 +56,6 @@ export const CheckboxMixin = (parent, bem) => ({
<div
class={bem()}
onClick={event => {
event.stopPropagation();
this.$emit('click', event);
}}
>

View File

@ -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) || [

View File

@ -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>

View File

@ -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>

View File

@ -5218,7 +5218,7 @@ jest-changed-files@^24.8.0:
execa "^1.0.0"
throat "^4.0.0"
jest-cli@^24.8.0:
jest-cli@^24.7.1:
version "24.8.0"
resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.8.0.tgz#b075ac914492ed114fa338ade7362a301693e989"
integrity sha512-+p6J00jSMPQ116ZLlHJJvdf8wbjNbZdeSX9ptfHX06/MSNaXmKihQzx5vQcw0q2G6JsdVkUIdWbOWtSnaYs3yA==