Skip to content

Commit

Permalink
fix(common): allow null/undefined to be passed to ngClass input (angu…
Browse files Browse the repository at this point in the history
…lar#39280)

With strict template type checking, a null/undefined value will raise an
error. However the implementation is completely fine with it, and it
would be pointless to "fix" it at the callsite and convert to e.g. an
empty string. Allow all of the "supported types" to be passed in
directly to ngClass.

Fixes angular#39280
  • Loading branch information
imirkin committed Jul 21, 2022
1 parent 46c44de commit 08a6175
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion goldens/public-api/common/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ export class NgClass implements DoCheck {
// (undocumented)
set ngClass(value: string | string[] | Set<string> | {
[klass: string]: any;
});
} | null | undefined);
// (undocumented)
ngDoCheck(): void;
// (undocumented)
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/directives/ng_class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class NgClass implements DoCheck {
}

@Input('ngClass')
set ngClass(value: string|string[]|Set<string>|{[klass: string]: any}) {
set ngClass(value: string|string[]|Set<string>|{[klass: string]: any}|null|undefined) {
this._removeClasses(this._rawClass);
this._applyClasses(this._initialClasses);

Expand Down

0 comments on commit 08a6175

Please sign in to comment.