@@ -12,10 +12,12 @@ import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, SchemaMetadata} from '../../me
1212import { throwError } from '../../util/assert' ;
1313import { getComponentDef } from '../def_getters' ;
1414import { ComponentDef } from '../interfaces/definition' ;
15- import { TNodeType } from '../interfaces/node' ;
15+ import { TElementNode , TNode , TNodeType } from '../interfaces/node' ;
1616import { RComment , RElement } from '../interfaces/renderer_dom' ;
17- import { CONTEXT , DECLARATION_COMPONENT_VIEW , LView } from '../interfaces/view' ;
17+ import { isDirectiveHost } from '../interfaces/type_checks' ;
18+ import { CONTEXT , DECLARATION_COMPONENT_VIEW , LView , TVIEW } from '../interfaces/view' ;
1819import { isAnimationProp } from '../util/attrs_utils' ;
20+ import { getNativeByTNode } from '../util/view_utils' ;
1921
2022let shouldThrowErrorOnUnknownElement = false ;
2123
@@ -65,27 +67,22 @@ export function ɵgetUnknownPropertyStrictMode() {
6567 * - the element matches any directive
6668 * - the element is allowed by one of the schemas
6769 *
68- * @param element Element to validate
69- * @param lView An `LView` that represents a current component that is being rendered
70- * @param tagName Name of the tag to check
71- * @param schemas Array of schemas
72- * @param hasDirectives Boolean indicating that the element matches any directive
70+ * @param lView An `LView` associated with a template is being rendered
71+ * @param tNode TNode representing an element to be validated
7372 */
74- export function validateElementIsKnown (
75- element : RElement ,
76- lView : LView ,
77- tagName : string | null ,
78- schemas : SchemaMetadata [ ] | null ,
79- hasDirectives : boolean ,
80- ) : void {
73+ export function validateElementIsKnown ( lView : LView , tNode : TElementNode ) : void {
74+ const tView = lView [ TVIEW ] ;
75+
8176 // If `schemas` is set to `null`, that's an indication that this Component was compiled in AOT
8277 // mode where this check happens at compile time. In JIT mode, `schemas` is always present and
8378 // defined as an array (as an empty array in case `schemas` field is not defined) and we should
8479 // execute the check below.
85- if ( schemas === null ) return ;
80+ if ( tView . schemas === null ) return ;
81+
82+ const tagName = tNode . value ;
8683
8784 // If the element matches any directive, it's considered as valid.
88- if ( ! hasDirectives && tagName !== null ) {
85+ if ( ! isDirectiveHost ( tNode ) && tagName !== null ) {
8986 // The element is unknown if it's an instance of HTMLUnknownElement, or it isn't registered
9087 // as a custom element. Note that unknown elements with a dash in their name won't be instances
9188 // of HTMLUnknownElement in browsers that support web components.
@@ -94,12 +91,12 @@ export function validateElementIsKnown(
9491 // Domino doesn't expose HTMLUnknownElement globally.
9592 ( typeof HTMLUnknownElement !== 'undefined' &&
9693 HTMLUnknownElement &&
97- element instanceof HTMLUnknownElement ) ||
94+ getNativeByTNode ( tNode , lView ) instanceof HTMLUnknownElement ) ||
9895 ( typeof customElements !== 'undefined' &&
9996 tagName . indexOf ( '-' ) > - 1 &&
10097 ! customElements . get ( tagName ) ) ;
10198
102- if ( isUnknown && ! matchingSchemas ( schemas , tagName ) ) {
99+ if ( isUnknown && ! matchingSchemas ( tView . schemas , tagName ) ) {
103100 const isHostStandalone = isHostComponentStandalone ( lView ) ;
104101 const templateLocation = getTemplateLocationDetails ( lView ) ;
105102 const schemas = `'${ isHostStandalone ? '@Component' : '@NgModule' } .schemas'` ;
0 commit comments