Merge pull request #2059 from SergioCrisostomo/add-input-event
fire change on "input" event
This commit is contained in:
commit
9ca05a64da
1 changed files with 9 additions and 9 deletions
|
@ -24,6 +24,7 @@
|
|||
@focus="focus"
|
||||
@blur="blur"
|
||||
@keydown.stop="keyDown"
|
||||
@input="change"
|
||||
@change="change"
|
||||
:readonly="readonly || !editable"
|
||||
:name="name"
|
||||
|
@ -38,9 +39,6 @@
|
|||
const prefixCls = 'ivu-input-number';
|
||||
const iconPrefixCls = 'ivu-icon';
|
||||
|
||||
function isValueNumber (value) {
|
||||
return (/(^-?[0-9]+\.{1}\d+$)|(^-?[1-9][0-9]*$)|(^-?0{1}$)/).test(value + '');
|
||||
}
|
||||
function addNum (num1, num2) {
|
||||
let sq1, sq2, m;
|
||||
try {
|
||||
|
@ -256,11 +254,13 @@
|
|||
change (event) {
|
||||
let val = event.target.value.trim();
|
||||
|
||||
const max = this.max;
|
||||
const min = this.min;
|
||||
if (event.type == 'input' && val.match(/^\-?\.?$|\.$/)) return; // prevent fire early if decimal. If no more input the change event will fire later
|
||||
if (event.type == 'change' && Number(val) === this.currentValue) return; // already fired change for input event
|
||||
|
||||
if (isValueNumber(val)) {
|
||||
val = Number(val);
|
||||
const {min, max} = this;
|
||||
const isEmptyString = val.length === 0;
|
||||
val = Number(val);
|
||||
if (!isNaN(val) && !isEmptyString) {
|
||||
this.currentValue = val;
|
||||
|
||||
if (val > max) {
|
||||
|
@ -275,8 +275,8 @@
|
|||
}
|
||||
},
|
||||
changeVal (val) {
|
||||
if (isValueNumber(val) || val === 0) {
|
||||
val = Number(val);
|
||||
val = Number(val);
|
||||
if (!isNaN(val)) {
|
||||
const step = this.step;
|
||||
|
||||
this.upDisabled = val + step > this.max;
|
||||
|
|
Loading…
Add table
Reference in a new issue