-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Align with Ember's HistoryLocation router
- Loading branch information
1 parent
3d0cd5b
commit 605d9ea
Showing
6 changed files
with
6,106 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
import Ember from 'ember'; | ||
|
||
const uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => { | ||
const r = Math.random() * 16 | 0; | ||
const v = c === 'x' ? r : r & 3 | 8; | ||
return v.toString(16); | ||
}); | ||
|
||
const { | ||
get, | ||
HistoryLocation, | ||
} = Ember; | ||
|
||
export default HistoryLocation.extend({ | ||
init(...args) { | ||
this._super(...args); | ||
this.stateCounter = 0; | ||
}, | ||
pushState(path) { | ||
const id = `${this.stateCounter++}`; | ||
const state = { path, id }; | ||
const state = { path, uuid: uuid() }; | ||
get(this, 'history').pushState(state, null, path); | ||
this._previousURL = this.getURL(); // eslint-disable-line no-underscore-dangle | ||
this.previousURL = this.getURL(); | ||
}, | ||
replaceState(path) { | ||
const id = `${this.stateCounter++}`; | ||
const state = { path, id }; | ||
const state = { path, uuid: uuid() }; | ||
get(this, 'history').replaceState(state, null, path); | ||
this._previousURL = this.getURL(); // eslint-disable-line no-underscore-dangle | ||
this.previousURL = this.getURL(); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.