mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
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:
@@ -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 '*';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user