File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -450,11 +450,19 @@ export class ElementWithUtils<T extends HTMLElement = HTMLElement> {
450450 return new ElementWithUtils ( wrapperElement as T ) ;
451451 }
452452
453+ private hasValue ( ) : this is ElementWithUtils < ElementWithValue > {
454+ return (
455+ this . native instanceof HTMLInputElement ||
456+ this . native instanceof HTMLTextAreaElement ||
457+ this . native instanceof HTMLSelectElement
458+ ) ;
459+ }
460+
453461 /**
454462 * Set value of input or textarea to a string.
455463 */
456464 setValue ( this : ElementWithUtils < ElementWithValue > , value : string ) : this {
457- if ( this . native instanceof HTMLInputElement ) {
465+ if ( this . hasValue ( ) ) {
458466 this . native . value = value ;
459467 }
460468 return this as unknown as this;
@@ -465,10 +473,10 @@ export class ElementWithUtils<T extends HTMLElement = HTMLElement> {
465473 * @returns The value of the element, or undefined if the element is not an input or textarea.
466474 */
467475 getValue ( this : ElementWithUtils < ElementWithValue > ) : string | undefined {
468- if ( ! ( this . native instanceof HTMLInputElement ) ) {
469- return undefined ;
476+ if ( this . hasValue ( ) ) {
477+ return this . native . value ;
470478 }
471- return this . native . value ;
479+ return undefined ;
472480 }
473481
474482 /**
You can’t perform that action at this time.
0 commit comments