Skip to content
This repository has been archived by the owner on May 30, 2020. It is now read-only.

Commit

Permalink
refactor: change onpopstate to onhashchange
Browse files Browse the repository at this point in the history
  • Loading branch information
sundowndev committed May 14, 2019
1 parent da268f2 commit 608b18b
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions src/leafeon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,15 @@ class RouterRequest {
* @returns {string}
*/
public getURI = (): string => {
if (typeof window !== 'undefined') {
return this.URI = this.formatPath(window.location.hash);
} else {
return this.URI = this.formatPath(this.windowObj.location.hash);
}
return this.URI = this.formatPath(this.windowObj.location.hash);
}

/**
* @function setURI
* @param route string
*/
public setURI = (route: string): void => {
if (typeof window !== 'undefined') {
window.location.hash = route;
} else {
this.windowObj.location.hash = route;
}
this.windowObj.location.hash = route;
}

/**
Expand Down Expand Up @@ -76,12 +68,12 @@ class RouterRequest {
}

/**
* @function setURI
* @function windowListener
* @param route string
*/
public windowListener = (callback: Function): void => {
if (typeof window !== 'undefined') {
window.onpopstate = () => {
window.onhashchange = () => {
callback();
};
}
Expand Down

0 comments on commit 608b18b

Please sign in to comment.