refactor(compiler): cleanup unsafe usage of null value for ng-content selector (#44411)

This commit improves the null-safety of the ng-content selector and
updates a comment that turned out to be slightly inaccurate.

Closes #38407

PR Close #44411
This commit is contained in:
JoostK
2021-12-08 19:45:59 +01:00
committed by Dylan Hunn
parent 722d8ef880
commit e8812bc04e
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -177,7 +177,7 @@ export interface R3ComponentMetadata extends R3DirectiveMetadata {
nodes: t.Node[];
/**
* Any ng-content selectors extracted from the template. Contains `null` when an ng-content
* Any ng-content selectors extracted from the template. Contains `*` when an ng-content
* element without selector is present.
*/
ngContentSelectors: string[];
@@ -20,7 +20,7 @@ const NG_NON_BINDABLE_ATTR = 'ngNonBindable';
const NG_PROJECT_AS = 'ngProjectAs';
export function preparseElement(ast: html.Element): PreparsedElement {
let selectAttr: string = null!;
let selectAttr: string|null = null;
let hrefAttr: string = null!;
let relAttr: string = null!;
let nonBindable = false;
@@ -71,7 +71,7 @@ export class PreparsedElement {
}
function normalizeNgContentSelect(selectAttr: string): string {
function normalizeNgContentSelect(selectAttr: string|null): string {
if (selectAttr === null || selectAttr.length === 0) {
return '*';
}