fix mask textarea

This commit is contained in:
Yanzhen Yu
2020-07-18 13:48:38 +08:00
parent c206e100f1
commit 3ebdcbdf03
2 changed files with 9 additions and 5 deletions

View File

@@ -237,6 +237,8 @@ function serializeNode(
tagName === 'select' tagName === 'select'
) { ) {
const value = (n as HTMLInputElement | HTMLTextAreaElement).value; const value = (n as HTMLInputElement | HTMLTextAreaElement).value;
const needBlockTextarea =
tagName === 'textarea' && maskInputOptions.textarea;
if ( if (
attributes.type !== 'radio' && attributes.type !== 'radio' &&
attributes.type !== 'checkbox' && attributes.type !== 'checkbox' &&
@@ -244,11 +246,11 @@ function serializeNode(
attributes.type !== 'button' && attributes.type !== 'button' &&
value value
) { ) {
attributes.value = maskInputOptions[ attributes.value =
attributes.type as keyof MaskInputOptions maskInputOptions[attributes.type as keyof MaskInputOptions] ||
] needBlockTextarea
? '*'.repeat(value.length) ? '*'.repeat(value.length)
: value; : value;
} else if ((n as HTMLInputElement).checked) { } else if ((n as HTMLInputElement).checked) {
attributes.checked = (n as HTMLInputElement).checked; attributes.checked = (n as HTMLInputElement).checked;
} }

View File

@@ -83,4 +83,6 @@ export type MaskInputOptions = Partial<{
time: boolean; time: boolean;
url: boolean; url: boolean;
week: boolean; week: boolean;
// unify textarea element with text input
textarea: boolean;
}>; }>;