Prevents error if sl-input has value undefined (#513)

The sl-input's value state being `undefined` is very common when using shoelace with frameworks. Instead of erroring out and not showing the input, this should handle it gracefully.
This commit is contained in:
Sidharth Ramesh
2021-08-30 17:55:25 +05:30
committed by GitHub
parent 147a8d2f57
commit da3415d029

View File

@@ -295,7 +295,7 @@ export default class SlInput extends LitElement {
'input--pill': this.pill,
'input--disabled': this.disabled,
'input--focused': this.hasFocus,
'input--empty': this.value.length === 0,
'input--empty': this.value?.length === 0,
'input--invalid': this.invalid
})}
>
@@ -344,7 +344,7 @@ export default class SlInput extends LitElement {
@blur=${this.handleBlur}
/>
${this.clearable && this.value.length > 0
${this.clearable && this.value?.length > 0
? html`
<button
part="clear-button"