visitElement method
void
visitElement(
- ElementAst ast, [
- _MissingDirectiveContext? _
])
override
Implementation
@override
void visitElement(ng.ElementAst ast, [_]) {
final selectorsGroup = _selectorsGroup(ast.directives);
final skipValidationSelectors =
CssSelector.parse(ast.skipSchemaValidationForSelector);
// checks whether a selector in @skipSchemaValidationFor is unused.
if (ast.skipSchemaValidationForSelector.isNotEmpty &&
_hasUnusedSelector(ast, skipValidationSelectors)) {
CompileContext.current.reportAndRecover(
BuildError.forSourceSpan(
ast.sourceSpan,
'A selector in @skipSchemaValidationFor="'
'${ast.skipSchemaValidationForSelector}" does not match this '
'element.\n$optedOutValidator',
),
);
}
final elementName = _extractXhtml(ast.name);
if (!(_matchedSelectorWithElement(skipValidationSelectors, elementName) ||
detectHtmlElementFromTagName(elementName) ||
_hasMatchedSelector(selectorsGroup, elementName) ||
_matchedSelectorWithElement(
ast.matchedNgContentSelectors, elementName) ||
hasElementInAllowlist(elementName) ||
elementName.startsWith('@svg'))) {
CompileContext.current.reportAndRecover(
BuildError.forSourceSpan(
ast.sourceSpan,
"Can't find '<$elementName>'. Please check that the spelling "
'is correct, and that the intended component is included in the '
"host component's list of directives. "
'See more details go/skipschemavalidationfor.\n$optedOutValidator',
),
);
}
super.visitElement(
ast,
_MissingDirectiveContext(
elementName,
ast.directives,
selectorsGroup,
ast.matchedNgContentSelectors,
skipValidationSelectors,
attributeDeps: ast.attributeDeps,
),
);
}