refactor(SwipeCell): remove deprecated on-close

This commit is contained in:
chenjiahan 2020-08-09 20:52:55 +08:00
parent 448584a146
commit 8031c690dd
4 changed files with 2 additions and 43 deletions

View File

View File

@ -41,13 +41,14 @@ Vant 遵循 [Semver](https://semver.org/lang/zh-CN/) 语义化版本规范。
以下改动是为了规范 API 命名:
- SwipeCell: `on-close` 属性重命名为 `before-close`,并调整参数结构
- Toast: `mask` 属性重命名为 `overlay`
- TreeSelect: `navclick` 事件重命名为 `click-nav`
- TreeSelect: `itemclick` 事件重命名为 `click-item`
##### 重命名徽标属性
在之前的版本中,我们通过 info 属性来展示图标右上角的徽标信息,为了表达更符合社区的命名习惯,我们将这个属性重命名为 badge影响以下组件
在之前的版本中,我们通过 info 属性来展示图标右上角的徽标信息,为了更符合社区的命名习惯,我们将这个属性重命名为 badge影响以下组件
- Tab
- Icon

View File

@ -20,9 +20,6 @@ export default createComponent({
],
props: {
// @deprecated
// should be removed in next major version, use beforeClose instead
onClose: Function,
disabled: Boolean,
leftWidth: [Number, String],
rightWidth: [Number, String],
@ -177,8 +174,6 @@ export default createComponent({
name: this.name,
instance: this,
});
} else if (this.onClose) {
this.onClose(position, this, { name: this.name });
} else {
this.close(position);
}

View File

@ -41,43 +41,6 @@ test('drag and show right part', () => {
expect(wrapper).toMatchSnapshot();
});
test('on-close prop', () => {
let position;
let instance;
const wrapper = mount(SwipeCell, {
...defaultProps,
propsData: {
...defaultProps.propsData,
onClose(pos, ins) {
position = pos;
instance = ins;
},
},
});
wrapper.trigger('click');
expect(position).toEqual(undefined);
wrapper.vm.open('left');
wrapper.trigger('click');
expect(position).toEqual('cell');
wrapper.find('.van-swipe-cell__left').trigger('click');
expect(position).toEqual('left');
wrapper.find('.van-swipe-cell__right').trigger('click');
expect(position).toEqual('right');
instance.close();
expect(instance.offset).toEqual(0);
instance.open('left');
wrapper.setData({ onClose: null });
wrapper.trigger('click');
expect(wrapper.vm.offset).toEqual(0);
});
test('before-close prop', () => {
let position;
let instance;