@@ -10,12 +10,13 @@ import {bindingUpdated} from '../bindings';
1010import { ɵCONTROL , ɵControl } from '../interfaces/control' ;
1111import { ComponentDef } from '../interfaces/definition' ;
1212import { InputFlags } from '../interfaces/input_flags' ;
13- import { TNode , TNodeFlags } from '../interfaces/node' ;
13+ import { TElementNode , TNode , TNodeFlags , TNodeType } from '../interfaces/node' ;
1414import { Renderer } from '../interfaces/renderer' ;
1515import { SanitizerFn } from '../interfaces/sanitization' ;
1616import { isComponentHost } from '../interfaces/type_checks' ;
1717import { LView , RENDERER , TView } from '../interfaces/view' ;
1818import { getCurrentTNode , getLView , getSelectedTNode , getTView , nextBindingIndex } from '../state' ;
19+ import { isNameOnlyAttributeMarker } from '../util/attrs_utils' ;
1920import { getNativeByTNode } from '../util/view_utils' ;
2021import { listenToOutput } from '../view/directive_outputs' ;
2122import { listenToDomEvent , wrapListener } from '../view/listeners' ;
@@ -131,12 +132,11 @@ function getControlDirectiveFirstCreatePass<T>(
131132 }
132133 }
133134
134- const nativeElement = lView [ tNode . index ] ;
135- if ( isNativeControl ( nativeElement ) ) {
136- if ( isNumericInput ( nativeElement ) ) {
135+ if ( isNativeControl ( tNode ) ) {
136+ if ( isNumericInput ( tNode ) ) {
137137 tNode . flags |= TNodeFlags . isNativeNumericControl ;
138138 }
139- if ( isTextControl ( nativeElement ) ) {
139+ if ( isTextControl ( tNode ) ) {
140140 tNode . flags |= TNodeFlags . isNativeTextControl ;
141141 }
142142 return control ;
@@ -259,12 +259,12 @@ interface HTMLTextAreaElementNarrowed extends HTMLTextAreaElement {
259259 */
260260type NativeControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElementNarrowed ;
261261
262- function isNativeControl ( element : unknown ) : element is NativeControlElement {
263- return (
264- element instanceof HTMLInputElement ||
265- element instanceof HTMLSelectElement ||
266- element instanceof HTMLTextAreaElement
267- ) ;
262+ function isNativeControl ( tNode : TNode ) : tNode is TElementNode {
263+ if ( tNode . type !== TNodeType . Element ) {
264+ return false ;
265+ }
266+ const tagName = tNode . value ;
267+ return tagName === 'input' || tagName === 'textarea' || tagName === 'select' ;
268268}
269269
270270/**
@@ -402,17 +402,33 @@ function isDateOrNull(value: unknown): value is Date | null {
402402}
403403
404404/** Returns whether `control` has a numeric input type. */
405- function isNumericInput ( control : NativeControlElement ) {
406- switch ( control . type ) {
407- case 'date' :
408- case 'datetime-local' :
409- case 'month' :
410- case 'number' :
411- case 'range' :
412- case 'time' :
413- case 'week' :
414- return true ;
405+ function isNumericInput ( tNode : TElementNode ) : boolean {
406+ if ( ! tNode . attrs || tNode . value !== 'input' ) {
407+ return false ;
415408 }
409+
410+ for ( let i = 0 ; i < tNode . attrs . length ; i += 2 ) {
411+ const name = tNode . attrs [ i ] ;
412+
413+ if ( isNameOnlyAttributeMarker ( name ) ) {
414+ break ;
415+ }
416+
417+ if ( name === 'type' ) {
418+ const value = tNode . attrs [ i + 1 ] ;
419+
420+ return (
421+ value === 'date' ||
422+ value === 'datetime-local' ||
423+ value === 'month' ||
424+ value === 'number' ||
425+ value === 'range' ||
426+ value === 'time' ||
427+ value === 'week'
428+ ) ;
429+ }
430+ }
431+
416432 return false ;
417433}
418434
@@ -422,10 +438,8 @@ function isNumericInput(control: NativeControlElement) {
422438 * This is not the same as an input with `type="text"`, but rather any input that accepts
423439 * text-based input which includes numeric types.
424440 */
425- function isTextControl (
426- control : NativeControlElement ,
427- ) : control is Exclude < NativeControlElement , HTMLSelectElement > {
428- return ! ( control instanceof HTMLSelectElement ) ;
441+ function isTextControl ( tNode : TElementNode ) : boolean {
442+ return tNode . value !== 'select' ;
429443}
430444
431445/**
0 commit comments