Skip to content

Commit

Permalink
Suggested fix for issue single-spa#113
Browse files Browse the repository at this point in the history
  • Loading branch information
jones-starz committed Aug 3, 2020
1 parent 6170374 commit cc64911
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/src/extra-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class SingleSpaPlatformLocation extends ɵBrowserPlatformLocation {

// This is a simple marker that helps us to ignore PopStateEvents
// that was not dispatched by the browser.
private skipNextPopState = false;
private skipNextPopState = 0;

private onPopStateListeners: ((event: LocationChangeEvent) => void)[] = [];

Expand All @@ -34,12 +34,12 @@ export class SingleSpaPlatformLocation extends ɵBrowserPlatformLocation {
}

pushState(state: any, title: string, url: string): void {
this.skipNextPopState = true;
this.skipNextPopState++;
super.pushState(state, title, url);
}

replaceState(state: any, title: string, url: string): void {
this.skipNextPopState = true;
this.skipNextPopState++;
super.replaceState(state, title, url);
}

Expand All @@ -52,8 +52,8 @@ export class SingleSpaPlatformLocation extends ɵBrowserPlatformLocation {
.singleSpa;

if (this.skipNextPopState && popStateEventWasDispatchedBySingleSpa) {
this.skipNextPopState = false;
} else {
this.skipNextPopState++;
} else if (this.skipNextPopState === 0) {
// Wrap any event listener into zone that is specific to some application.
// The main issue is `back/forward` buttons of browsers, because they invoke
// `history.back|forward` which dispatch `popstate` event. Since `single-spa`
Expand Down

0 comments on commit cc64911

Please sign in to comment.