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 auto-location #882

Merged
merged 1 commit into from
Dec 20, 2021
Merged
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
42 changes: 42 additions & 0 deletions content/ember/v4/auto-location.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
id: deprecate-auto-location
title: AutoLocation Class
until: '5.0.0'
since: '4.1.0'
---

#### Background

Several years ago only some browsers supported the (then) new History Location API.
Others could only serialize the router location into an url hash `my/path#/ember/route`.

To handle this dynamically, Ember built an AutoLocation that would feature-detect
and use either 'hash' or 'history' as the underlying mechanism.

These days, virtually all browsers support the history API, so this is what 'auto'
will resolve to in almost every case. Since 'auto' has served its purpose, it's being removed.

#### Required Changes

Set `locationType` in `config/environment.js` to `'history'`. This is it,
your app should work just like it used to.

Unless you know for sure that you need to keep feature detection in place (few need that),
or that you'd like to use the 'hash' location strategy (rarely used in browsers,
but can be useful for mobile apps delivered via a webview).

#### Advanced Stuff

If you implemented your own Location class and used the `detect` method,
this one is now deprecated. If you need feature detection you can run your
detection code in app.js, before setting the location type.

```js
// app/router.js
export default class Router extends EmberRouter {
location = (historyFeatureDetection() ? 'history' : 'hash');
// …
}
```

For more background, read the [RFC](https://github.com/emberjs/rfcs/blob/master/text/0711-deprecate-auto-location.md).