Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate locations/router-scroll for Embers own implementation #203

Merged
merged 2 commits into from
Jun 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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