diff --git a/src/vanilla/baseLocationService.ts b/src/vanilla/baseLocationService.ts index 15587e69..68055318 100644 --- a/src/vanilla/baseLocationService.ts +++ b/src/vanilla/baseLocationService.ts @@ -16,8 +16,8 @@ const Evt: typeof CustomEvent = getCustomEventCtor(); /** A base `LocationServices` */ export abstract class BaseLocationServices implements LocationServices, Disposable { constructor(router: UIRouter, public fireAfterUpdate: boolean) { - this._location = window && window.location; - this._history = window && window.history; + this._location = self && self.location; + this._history = self && self.history; } _listener = evt => this._listeners.forEach(cb => cb(evt)); diff --git a/src/vanilla/hashLocationService.ts b/src/vanilla/hashLocationService.ts index 4c3e36e2..9672e74f 100644 --- a/src/vanilla/hashLocationService.ts +++ b/src/vanilla/hashLocationService.ts @@ -11,7 +11,7 @@ import { BaseLocationServices } from "./baseLocationService"; export class HashLocationService extends BaseLocationServices { constructor(router: UIRouter) { super(router, false); - window.addEventListener('hashchange', this._listener, false); + self.addEventListener('hashchange', this._listener, false); } _get() { @@ -23,7 +23,7 @@ export class HashLocationService extends BaseLocationServices { dispose (router: UIRouter) { super.dispose(router); - window.removeEventListener('hashchange', this._listener); + self.removeEventListener('hashchange', this._listener); } } diff --git a/src/vanilla/pushStateLocationService.ts b/src/vanilla/pushStateLocationService.ts index 55161fca..57b044a7 100644 --- a/src/vanilla/pushStateLocationService.ts +++ b/src/vanilla/pushStateLocationService.ts @@ -19,7 +19,7 @@ export class PushStateLocationService extends BaseLocationServices { constructor(router: UIRouter) { super(router, true); this._config = router.urlService.config; - window.addEventListener("popstate", this._listener, false); + self.addEventListener("popstate", this._listener, false); }; _get() { @@ -42,7 +42,7 @@ export class PushStateLocationService extends BaseLocationServices { dispose(router: UIRouter) { super.dispose(router); - window.removeEventListener("popstate", this._listener); + self.removeEventListener("popstate", this._listener); } }