From 210decc4716b2e3e9b6f0c86678560797131bb4f Mon Sep 17 00:00:00 2001 From: Philip Sultanescu Date: Thu, 28 Feb 2019 06:11:17 +0100 Subject: [PATCH] fix: restore compatibility with universal Closes #83 --- src/resizable.directive.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/resizable.directive.ts b/src/resizable.directive.ts index 56c632a..7c75111 100644 --- a/src/resizable.directive.ts +++ b/src/resizable.directive.ts @@ -9,8 +9,11 @@ import { OnDestroy, NgZone, OnChanges, - SimpleChanges + SimpleChanges, + Inject, + PLATFORM_ID } from '@angular/core'; +import { isPlatformBrowser } from '@angular/common'; import { Subject, Observable, Observer, merge, EMPTY } from 'rxjs'; import { map, @@ -374,6 +377,7 @@ export class ResizableDirective implements OnInit, OnChanges, OnDestroy { * @hidden */ constructor( + @Inject(PLATFORM_ID) private platformId: any, private renderer: Renderer2, public elm: ElementRef, private zone: NgZone @@ -785,7 +789,10 @@ export class ResizableDirective implements OnInit, OnChanges, OnDestroy { * @hidden */ ngOnDestroy(): void { - this.renderer.setStyle(document.body, 'cursor', ''); + // browser check for angular universal, because it doesn't know what document is + if (isPlatformBrowser(this.platformId)) { + this.renderer.setStyle(document.body, 'cursor', ''); + } this.mousedown.complete(); this.mouseup.complete(); this.mousemove.complete();