Skip to content

Commit

Permalink
fix(Input): resolve value=0 is valid when type is number (#2108)
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Jun 20, 2023
1 parent 3bcf5d7 commit d8324c3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/input/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class Input extends SuperComponent {
prefix,
classPrefix: name,
classBasePrefix: prefix,
excludeType: ['number', 'digit'],
};

lifetimes = {
Expand Down Expand Up @@ -62,14 +63,15 @@ export default class Input extends SuperComponent {

methods = {
updateValue(value) {
const { maxcharacter, maxlength } = this.properties;
if (maxcharacter && maxcharacter > 0 && !Number.isNaN(maxcharacter)) {
const { maxcharacter, maxlength, type } = this.properties;
const { excludeType } = this.data;
if (!excludeType.includes(type) && maxcharacter && maxcharacter > 0 && !Number.isNaN(maxcharacter)) {
const { length, characters } = getCharacterLength('maxcharacter', value, maxcharacter);
this.setData({
value: characters,
count: length,
});
} else if (maxlength > 0 && !Number.isNaN(maxlength)) {
} else if (!excludeType.includes(type) && maxlength > 0 && !Number.isNaN(maxlength)) {
const { length, characters } = getCharacterLength('maxlength', value, maxlength);
this.setData({
value: characters,
Expand Down

0 comments on commit d8324c3

Please sign in to comment.