From 4f4cac8ddc7d1d0207fab034ad2cc7d45d746d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Mon, 26 Apr 2021 11:38:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dreadonly/disabled=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/input.wc | 6 +++--- src/form/link.wc | 8 ++++---- src/form/number.wc | 2 +- src/form/select.wc | 2 +- src/form/switch.wc | 3 ++- src/form/textarea.wc | 14 ++++++++------ 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/form/input.wc b/src/form/input.wc index f964da4..dc7c302 100644 --- a/src/form/input.wc +++ b/src/form/input.wc @@ -343,8 +343,8 @@ export default class Input { props = { value: '', placeholder: '', - maxlength: null, - minlength: null, + maxlength: 0, + minlength: 0, clearable: false, autofocus: false, readonly: false, @@ -608,7 +608,7 @@ export default class Input { break case 'value': - this.value = val + this.value = val || '' break case 'maxlength': diff --git a/src/form/link.wc b/src/form/link.wc index e36ec97..b8e0b5e 100644 --- a/src/form/link.wc +++ b/src/form/link.wc @@ -170,19 +170,19 @@ } // ------- -:host([type='default']) { +:host([type='help']) { color: var(--color-grey-2); &::after { border-color: var(--color-grey-1); } } -:host([type='default']:not([disabled]):hover) { +:host([type='help']:not([disabled]):hover) { color: var(--color-grey-1); } -:host([type='default']:not([disabled]):active) { +:host([type='help']:not([disabled]):active) { color: var(--color-grey-3); } -:host([type='default']:not([disabled]):focus-within) { +:host([type='help']:not([disabled]):focus-within) { box-shadow: 0 0 0 2px var(--color-grey-a); } diff --git a/src/form/number.wc b/src/form/number.wc index 11af83c..fda9d78 100644 --- a/src/form/number.wc +++ b/src/form/number.wc @@ -424,7 +424,7 @@ export default class Number { if (k === 'readonly') { k = 'readOnly' } - this[k] = true + this[k] = val !== null break } } diff --git a/src/form/select.wc b/src/form/select.wc index d4af4a4..bafec4a 100644 --- a/src/form/select.wc +++ b/src/form/select.wc @@ -494,7 +494,7 @@ export default class Select { if (k === 'readonly') { k = 'readOnly' } - this[k] = true + this[k] = val !== null break } } diff --git a/src/form/switch.wc b/src/form/switch.wc index 9356093..dc5e9ac 100644 --- a/src/form/switch.wc +++ b/src/form/switch.wc @@ -189,8 +189,9 @@ export default class Switch { switch (name) { case 'checked': case 'disabled': - this[name] = true + this[name] = val !== null break + case 'active-text': case 'inactive-text': console.log('------------->>>') diff --git a/src/form/textarea.wc b/src/form/textarea.wc index bc95167..0004098 100644 --- a/src/form/textarea.wc +++ b/src/form/textarea.wc @@ -1,7 +1,7 @@ @@ -139,8 +139,8 @@ export default class Textarea { props = { value: '', placeholder: '', - maxlength: null, - minlength: null, + maxlength: 0, + minlength: 0, autofocus: false, readonly: false, disabled: false, @@ -268,17 +268,19 @@ export default class Textarea { break case 'value': - this.value = val + this.value = val || '' break case 'maxlength': case 'minlength': if (val === null) { this.__INPUT__.removeAttribute(name) + this.props[name] = 0 } else { let n = +val if (n > 0) { - this.__INPUT__.setAttribute(name, +val) + this.__INPUT__.setAttribute(name, n) + this.props[name] = n } } break @@ -293,7 +295,7 @@ export default class Textarea { if (k === 'readonly') { k = 'readOnly' } - this[k] = true + this[k] = val !== null break } }