Skip to content

Commit

Permalink
fix: add checking for not udefined document object (#541)
Browse files Browse the repository at this point in the history
* Add checking for not udefined document object

* fix braces
  • Loading branch information
dimonzav authored and valorkin committed Jan 17, 2017
1 parent ad16168 commit 7330f47
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions components/select/off-click.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ export class OffClickDirective implements OnInit, OnDestroy {
}

public ngOnInit(): any {
setTimeout(() => {document.addEventListener('click', this.offClickHandler);}, 0);
setTimeout(() => { if(typeof document !== 'undefined') { document.addEventListener('click', this.offClickHandler); } }, 0);
}

public ngOnDestroy(): any {
document.removeEventListener('click', this.offClickHandler);
if(typeof document !== 'undefined') { document.removeEventListener('click', this.offClickHandler); }
}
}

0 comments on commit 7330f47

Please sign in to comment.