perf(Field): reduce input value assignment (#6489)

This commit is contained in:
neverland 2020-06-08 19:57:25 +08:00 committed by GitHub
parent 713c8e0101
commit 9adbfcb26c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -276,33 +276,25 @@ export default createComponent({
}
let { value } = target;
const { maxlength } = this;
const originValue = value;
// native maxlength not work when type is number
const { maxlength } = this;
if (isDef(maxlength) && value.length > maxlength) {
value = value.slice(0, maxlength);
target.value = value;
}
if (this.type === 'number' || this.type === 'digit') {
const originValue = value;
const allowDot = this.type === 'number';
value = formatNumber(value, allowDot);
if (value !== originValue) {
target.value = value;
}
}
if (this.formatter) {
const originValue = value;
value = this.formatter(value);
}
if (value !== originValue) {
target.value = value;
}
if (value !== originValue) {
target.value = value;
}
return value;