From 7e774bcff2a7cfe9799b20132b3b0896500fae46 Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 14 Feb 2019 18:53:51 +0800 Subject: [PATCH] [bugfix] SwipeCell: incorrect render when left-width equals zero (#2737) --- packages/swipe-cell/index.js | 8 ++++---- .../swipe-cell/test/__snapshots__/index.spec.js.snap | 6 ++++++ packages/swipe-cell/test/index.spec.js | 10 ++++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/packages/swipe-cell/index.js b/packages/swipe-cell/index.js index 72f56bbe8..4ccb08fd9 100644 --- a/packages/swipe-cell/index.js +++ b/packages/swipe-cell/index.js @@ -146,17 +146,17 @@ export default sfc({ this.swipe = false; }} > - {this.leftWidth && ( + {this.leftWidth ? (
{this.slots('left')}
- )} + ) : null} {this.slots()} - {this.rightWidth && ( + {this.rightWidth ? (
{this.slots('right')}
- )} + ) : null} ); diff --git a/packages/swipe-cell/test/__snapshots__/index.spec.js.snap b/packages/swipe-cell/test/__snapshots__/index.spec.js.snap index a48134c2e..d5ca12cbd 100644 --- a/packages/swipe-cell/test/__snapshots__/index.spec.js.snap +++ b/packages/swipe-cell/test/__snapshots__/index.spec.js.snap @@ -44,3 +44,9 @@ exports[`drag and show left part 5`] = ` `; + +exports[`width equals zero 1`] = ` +
+
+
+`; diff --git a/packages/swipe-cell/test/index.spec.js b/packages/swipe-cell/test/index.spec.js index 348a6f4c7..475f75293 100644 --- a/packages/swipe-cell/test/index.spec.js +++ b/packages/swipe-cell/test/index.spec.js @@ -64,3 +64,13 @@ test('on close prop', () => { wrapper.trigger('click'); expect(wrapper.vm.offset).toEqual(0); }); + +it('width equals zero', () => { + const wrapper = mount(SwipeCell, { + propsData: { + leftWidth: 0, + rightWidth: 0 + } + }); + expect(wrapper).toMatchSnapshot(); +});