Skip to content

Commit

Permalink
fix(vanilla): Use self instead of window for webworker compat
Browse files Browse the repository at this point in the history
Closes #62
  • Loading branch information
christopherthielen committed Sep 21, 2017
1 parent e883afc commit a4629ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/vanilla/baseLocationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions src/vanilla/hashLocationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
}

4 changes: 2 additions & 2 deletions src/vanilla/pushStateLocationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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);
}
}

0 comments on commit a4629ee

Please sign in to comment.