@@ -17,14 +17,18 @@ class TextInput extends BindingHandler {
1717 return 'textinput'
1818 }
1919
20- declare $element : HTMLInputElement
20+ get $inputElement ( ) : HTMLInputElement {
21+ return this . $element as HTMLInputElement
22+ }
23+
2124 previousElementValue : any
2225 elementValueBeforeEvent ?: ReturnType < typeof setTimeout >
2326 timeoutHandle ?: ReturnType < typeof setTimeout >
2427
2528 constructor ( ...args : [ any ] ) {
2629 super ( ...args )
27- this . previousElementValue = this . $element . value
30+
31+ this . previousElementValue = this . $inputElement . value
2832
2933 if ( options . debug && ( this . constructor as any ) . _forceUpdateOn ) {
3034 // Provide a way for tests to specify exactly which events are bound
@@ -58,7 +62,7 @@ class TextInput extends BindingHandler {
5862 }
5963
6064 updateModel ( event ) {
61- const element = this . $element
65+ const element = this . $inputElement
6266 clearTimeout ( this . timeoutHandle )
6367 this . elementValueBeforeEvent = this . timeoutHandle = undefined
6468 const elementValue = element . value
@@ -73,7 +77,7 @@ class TextInput extends BindingHandler {
7377 }
7478
7579 deferUpdateModel ( event : any ) {
76- const element = this . $element
80+ const element = this . $inputElement
7781 if ( ! this . timeoutHandle ) {
7882 // The elementValueBeforeEvent variable is set *only* during the brief gap between an
7983 // event firing and the updateModel function running. This allows us to ignore model
@@ -92,12 +96,12 @@ class TextInput extends BindingHandler {
9296 }
9397 if ( this . elementValueBeforeEvent !== undefined && modelValue === this . elementValueBeforeEvent ) {
9498 setTimeout ( this . updateView . bind ( this ) , 4 )
95- } else if ( this . $element . value !== modelValue ) {
99+ } else if ( this . $inputElement . value !== modelValue ) {
96100 // Update the element only if the element and model are different. On some browsers, updating the value
97101 // will move the cursor to the end of the input, which would be bad while the user is typing.
98102 this . previousElementValue = modelValue // Make sure we ignore events (propertychange) that result from updating the value
99- this . $element . value = modelValue
100- this . previousElementValue = this . $element . value // In case the browser changes the value (see #2281)
103+ this . $inputElement . value = modelValue
104+ this . previousElementValue = this . $inputElement . value // In case the browser changes the value (see #2281)
101105 }
102106 }
103107}
0 commit comments