From f19b9f13c62873700446206300235dda9cb2baea Mon Sep 17 00:00:00 2001 From: Haoran Yu Date: Wed, 17 Apr 2019 11:33:08 +0800 Subject: [PATCH] Rate: Fix decimal display support in disabled mode (#15089) --- packages/rate/src/main.vue | 5 ++--- test/unit/specs/rate.spec.js | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/rate/src/main.vue b/packages/rate/src/main.vue index 56f4d406..3845e7aa 100644 --- a/packages/rate/src/main.vue +++ b/packages/rate/src/main.vue @@ -148,9 +148,8 @@ decimalStyle() { let width = ''; if (this.rateDisabled) { - width = `${ this.valueDecimal < 50 ? 0 : 50 }%`; - } - if (this.allowHalf) { + width = `${ this.valueDecimal }%`; + } else if (this.allowHalf) { width = '50%'; } return { diff --git a/test/unit/specs/rate.spec.js b/test/unit/specs/rate.spec.js index c98932c5..70eedf37 100644 --- a/test/unit/specs/rate.spec.js +++ b/test/unit/specs/rate.spec.js @@ -181,7 +181,7 @@ describe('Rate', () => { const fourthStar = vm2.$el.querySelectorAll('.el-rate__item')[3]; const halfStar = fourthStar.querySelector('.el-rate__decimal'); - expect(halfStar.style.width).to.equal('0%'); + expect(halfStar.style.width).to.equal('40%'); }); it('allow half', () => {