Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

fix(media-marshaller): do not propagate undefined value #1245

Merged
merged 1 commit into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/core/media-marshaller/media-marshaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class MediaMarshaller {
const activatedBp = this.activatedBreakpoints[i];
const valueMap = bpMap.get(activatedBp.alias);
if (valueMap) {
if (key === undefined || valueMap.has(key)) {
if (key === undefined || (valueMap.has(key) && valueMap.get(key) !== undefined)) {
return valueMap;
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/lib/extended/class/class.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ describe('class directive', () => {
expectNativeEl(fixture).toHaveCssClass('mat-class');
});

it('should support more than one responsive breakpoint on one element with undefined', () => {
createTestComponent(`<div ngClass.lt-lg="mat-class" [ngClass.md]="undefined"></div>`);
mediaController.activate('md', true);
expectNativeEl(fixture).toHaveCssClass('mat-class');
});

it('should work with ngClass object notation', () => {
createTestComponent(`
<div [ngClass]="{'x1': hasX1, 'x3': hasX3}"
Expand Down