Skip to content

Commit

Permalink
Merge pull request #29 from fschick/allow-to-set-multple-classes-from…
Browse files Browse the repository at this point in the history
…-window-class
  • Loading branch information
NetanelBasal authored Mar 21, 2021
2 parents 2297d92 + 5ac3297 commit 57a67bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions projects/ngneat/dialog/src/lib/dialog.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,13 @@ describe('DialogComponent', () => {
expect(host).toBeTruthy();
expect(host).toBe(spectator.fixture.nativeElement);
});

it('should set multiple classes from windowClass at host element', () => {
spectator = createComponent(withConfig({ windowClass: ' test-class-1 test-class-2 ' }));

const host = spectator.query('.test-class-1.test-class-2', { root: true });

expect(host).toBeTruthy();
expect(host).toBe(spectator.fixture.nativeElement);
});
});
3 changes: 2 additions & 1 deletion projects/ngneat/dialog/src/lib/dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ export class DialogComponent implements OnInit, OnDestroy {
this.nodes.forEach(node => host.appendChild(node));

if (config.windowClass) {
host.classList.add(config.windowClass);
const classNames = config.windowClass.split(/\s/).filter(x => x);
classNames.forEach(name => host.classList.add(name));
}
}

Expand Down

0 comments on commit 57a67bd

Please sign in to comment.