Skip to content

Commit

Permalink
fix #6
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldshen committed Jun 5, 2019
1 parent 2d7d6f2 commit e3d9605
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/el-number-range.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
</div>
</template>
<script>
const isNum = n => typeof n === 'number'
export default {
name: 'ElNumberRange',
props: {
Expand Down Expand Up @@ -54,9 +52,9 @@ export default {
return this.value[0]
},
set(val) {
if (isNum(val)) {
if (this.isNum(val)) {
val = this.clamp(val)
if (isNum(this.maxValue)) val = Math.min(val, this.maxValue)
if (this.isNum(this.maxValue)) val = Math.min(val, this.maxValue)
} else {
val = undefined
}
Expand All @@ -68,9 +66,9 @@ export default {
return this.value[1]
},
set(val) {
if (isNum(val)) {
if (this.isNum(val)) {
val = this.clamp(val)
if (isNum(this.minValue)) val = Math.max(val, this.minValue)
if (this.isNum(this.minValue)) val = Math.max(val, this.minValue)
} else {
val = undefined
}
Expand All @@ -84,7 +82,8 @@ export default {
methods: {
clamp(val) {
return Math.max(this.min, Math.min(this.max, val))
}
},
isNum: n => typeof n === 'number'
}
}
</script>
Expand Down

0 comments on commit e3d9605

Please sign in to comment.