Skip to content

Commit

Permalink
Deprecate locations/router-scroll for Embers own implementation (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
snewcomer authored Jun 15, 2019
1 parent f1a3b3e commit 695d894
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
node_js:
# we recommend testing addons with the same minimum supported node version as Ember CLI
# so that your addon works for all apps
- "6"
- "8"

sudo: false
dist: trusty
Expand Down
19 changes: 19 additions & 0 deletions addon/locations/router-scroll.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import HistoryLocation from '@ember/routing/history-location';
import { set, get } from '@ember/object';
import { deprecate } from '@ember/application/deprecations';

const uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = Math.random() * 16 | 0;
Expand All @@ -9,12 +10,30 @@ const uuid = () => 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) =

export default HistoryLocation.extend({
pushState(path) {
deprecate(
`If you are overriding ember-router-scroll's implementation of "pushState", then you can subclass and override a new location object from: import HistoryLocation from '@ember/routing/history-location';`,
false,
{
id: 'ember-router-scroll',
until: '2.0.0'
}
);

const state = { path, uuid: uuid() };
get(this, 'history').pushState(state, null, path);
set(this, '_previousURL', this.getURL());
},

replaceState(path) {
deprecate(
`If you are overriding ember-router-scroll's implementation of "replaceState", then you can subclass and override a new location object from: import HistoryLocation from '@ember/routing/history-location';`,
false,
{
id: 'ember-router-scroll',
until: '2.0.0'
}
);

const state = { path, uuid: uuid() };
get(this, 'history').replaceState(state, null, path);
set(this, '_previousURL', this.getURL());
Expand Down

0 comments on commit 695d894

Please sign in to comment.