From 64fab5e64ddf867a649b864e6a79a1c6a9efb0de Mon Sep 17 00:00:00 2001 From: fadelguy <32434449+fadelguy@users.noreply.github.com> Date: Tue, 3 Apr 2018 09:40:53 +0300 Subject: [PATCH 1/5] Check if from browser --- modules/core/src/documentinterruptsource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/core/src/documentinterruptsource.ts b/modules/core/src/documentinterruptsource.ts index 9b575d8..5aaa292 100644 --- a/modules/core/src/documentinterruptsource.ts +++ b/modules/core/src/documentinterruptsource.ts @@ -1,11 +1,13 @@ +import { Inject, PLATFORM_ID } from '@/angular/core'; +import { isPlatformBrowser } from '@angular/common'; import { EventTargetInterruptOptions, EventTargetInterruptSource } from './eventtargetinterruptsource'; /* * An interrupt source that uses events on the document element (html tag). */ export class DocumentInterruptSource extends EventTargetInterruptSource { - constructor(events: string, options?: number | EventTargetInterruptOptions) { - super(document.documentElement, events, options); + constructor(events: string, options?: number | EventTargetInterruptOptions, @Inject(PLATFORM_ID) private platformId?: any) { + super(isPlatformBrowser(platformId) ? document.documentElement : null, events, options); } /* From 118a3cc47e42a5fc52daa84df8587a0567e39c23 Mon Sep 17 00:00:00 2001 From: fadelguy <32434449+fadelguy@users.noreply.github.com> Date: Tue, 3 Apr 2018 09:49:26 +0300 Subject: [PATCH 2/5] Check is from browser --- modules/core/src/windowinterruptsource.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/core/src/windowinterruptsource.ts b/modules/core/src/windowinterruptsource.ts index c82f808..695d000 100644 --- a/modules/core/src/windowinterruptsource.ts +++ b/modules/core/src/windowinterruptsource.ts @@ -1,10 +1,12 @@ +import { Inject, PLATFORM_ID } from '@angular/core'; +import { isPlatformBrowser } from '@angular/common'; import {EventTargetInterruptOptions, EventTargetInterruptSource} from './eventtargetinterruptsource'; /* * An interrupt source on the Window object. */ export class WindowInterruptSource extends EventTargetInterruptSource { - constructor(events: string, options?: number | EventTargetInterruptOptions) { - super(window, events, options); + constructor(events: string, options?: number | EventTargetInterruptOptions, @Inject(PLATFORM_ID) private platformId: any) { + super(isPlatformBrowser(platformId) ? window : null, events, options); } } From 3e28d6929253f6851d3cab9fad7cdb8596d9283c Mon Sep 17 00:00:00 2001 From: fadelguy <32434449+fadelguy@users.noreply.github.com> Date: Tue, 3 Apr 2018 09:58:13 +0300 Subject: [PATCH 3/5] Don't create fromEvent if from server --- modules/core/src/eventtargetinterruptsource.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/src/eventtargetinterruptsource.ts b/modules/core/src/eventtargetinterruptsource.ts index 072713a..2dbcd90 100644 --- a/modules/core/src/eventtargetinterruptsource.ts +++ b/modules/core/src/eventtargetinterruptsource.ts @@ -53,6 +53,9 @@ export class EventTargetInterruptSource extends InterruptSource { this.passive = !!options.passive; const opts = this.passive ? { passive: true } : null; + if(target == null) { + return; + } const fromEvents = events.split(' ').map(eventName => Observable.fromEvent(target, eventName, opts)); this.eventSrc = Observable.merge(...fromEvents); this.eventSrc = this.eventSrc.filter(innerArgs => !this.filterEvent(innerArgs)); From 7b310c28a1680430c0d6838b67c7a8bcc8bda1ce Mon Sep 17 00:00:00 2001 From: fadelguy <32434449+fadelguy@users.noreply.github.com> Date: Tue, 3 Apr 2018 13:40:45 +0300 Subject: [PATCH 4/5] Update documentinterruptsource.ts --- modules/core/src/documentinterruptsource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/documentinterruptsource.ts b/modules/core/src/documentinterruptsource.ts index 5aaa292..5244240 100644 --- a/modules/core/src/documentinterruptsource.ts +++ b/modules/core/src/documentinterruptsource.ts @@ -1,4 +1,4 @@ -import { Inject, PLATFORM_ID } from '@/angular/core'; +import { Inject, PLATFORM_ID } from '@angular/core'; import { isPlatformBrowser } from '@angular/common'; import { EventTargetInterruptOptions, EventTargetInterruptSource } from './eventtargetinterruptsource'; From ecfe4c72bfc9d990df614ffd0dd259290db573df Mon Sep 17 00:00:00 2001 From: fadelguy <32434449+fadelguy@users.noreply.github.com> Date: Tue, 3 Apr 2018 13:49:42 +0300 Subject: [PATCH 5/5] Update windowinterruptsource.ts --- modules/core/src/windowinterruptsource.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/windowinterruptsource.ts b/modules/core/src/windowinterruptsource.ts index 695d000..f53eb1c 100644 --- a/modules/core/src/windowinterruptsource.ts +++ b/modules/core/src/windowinterruptsource.ts @@ -6,7 +6,7 @@ import {EventTargetInterruptOptions, EventTargetInterruptSource} from './eventta * An interrupt source on the Window object. */ export class WindowInterruptSource extends EventTargetInterruptSource { - constructor(events: string, options?: number | EventTargetInterruptOptions, @Inject(PLATFORM_ID) private platformId: any) { + constructor(events: string, options?: number | EventTargetInterruptOptions, @Inject(PLATFORM_ID) private platformId?: any) { super(isPlatformBrowser(platformId) ? window : null, events, options); } }