Skip to content

Commit 4c0a7c2

Browse files
committed
feat: use 'DOCUMENT' of '@angular/common' instead of 'document' of window
1 parent 5b6370f commit 4c0a7c2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/app/containers/default-layout/default-layout.component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import {Component, OnDestroy} from '@angular/core';
1+
import {Component, OnDestroy, Inject} from '@angular/core';
2+
import { DOCUMENT } from '@angular/common';
23
import { navItems } from './../../_nav';
34

5+
46
@Component({
57
selector: 'app-dashboard',
68
templateUrl: './default-layout.component.html'
@@ -9,17 +11,19 @@ export class DefaultLayoutComponent implements OnDestroy {
911
public navItems = navItems;
1012
public sidebarMinimized = true;
1113
private changes: MutationObserver;
12-
public element: HTMLElement = document.body;
13-
constructor() {
14+
public element: HTMLElement ;
15+
constructor(@Inject(DOCUMENT) _document?: any) {
1416

1517
this.changes = new MutationObserver((mutations) => {
16-
this.sidebarMinimized = document.body.classList.contains('sidebar-minimized');
18+
this.sidebarMinimized = _document.body.classList.contains('sidebar-minimized');
1719
});
1820

1921
this.changes.observe(<Element>this.element, {
2022
attributes: true,
2123
attributeFilter: [ 'class' ]
2224
});
25+
26+
this.element = _document.body;
2327
}
2428

2529
ngOnDestroy(): void {

0 commit comments

Comments
 (0)