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

feat(router): Add feature provider for enabling hash navigation #48301

Closed
wants to merge 1 commit into from

Conversation

atscott
Copy link
Contributor

@atscott atscott commented Nov 30, 2022

The argument against this feature:

This isn't a navigation strategy that's very commonly desired. Secondly, the hash strategy is a location configuration in @angular/common and you can use it outside of the Router or with any custom router implementations. So while the net effect of using the router is that it updates the URL which is controlled by the strategy, this feature provider doesn't necessarily need to exist in the Router. The location strategy is an application-wide configuration and affects anything that imports Location. Of course, the Router does this in a few places but plenty of other things might as well.

The argument for this feature:

  • Discoverability. While LocationStrategy is technically in @angular/common, the most common use-case is when using it with the Router.
  • Precedence in the RouterModule.forRoot([], {useHash: true})
  • Precedence in other routing libraries (createWebHashHistory in VueJS and HashRouter in React, for example)
  • The implementation of withHashLocation is much more clear than useHash was. You can look at the function and see that all it's doing is adding the HashLocationStrategy to the providers list.

resolves #48295 / #47986

@atscott atscott added feature Issue that requests a new feature area: router target: minor This PR is targeted for the next minor release labels Nov 30, 2022
@ngbot ngbot bot modified the milestone: Backlog Nov 30, 2022
@angular-robot angular-robot bot added the detected: feature PR contains a feature commit label Nov 30, 2022
The argument against this feature:

Firstly, this isn't a navigation strategy that's very commonly desired.
Secondly, the hash strategy is a location configuration in `@angular/common`
and you can use it outside of the Router or with any custom router implementations.
So while the net effect of using the router is that it updates the URL which is
controlled by the strategy, this feature provider doesn't necessarily need to
exist in the Router. The location strategy is an application-wide configuration
and affects anything that imports `Location`.  Of course, the Router does this
in a few places but plenty of other things might as well.

The argument for this feature:

* Discoverability. While `LocationStrategy` is technically in `@angular/common`, the most
  common use-case _is_ when using it with the Router.
* Precedence in the `RouterModule.forRoot([], {useHash: true})`
* Precedence in other routing libraries (`createWebHashHistory` in VueJS
  and `HashRouter` in React, for example)
* The implementation of `withHashLocation` is much more clear than
  `useHash` was. You can look at the function and see that all it's
  doing is adding the `HashLocationStrategy` to the providers list.

resolves angular#48295 / angular#47986
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

Copy link
Member

@pkozlowski-opensource pkozlowski-opensource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reviewed-for: public-api

@pkozlowski-opensource pkozlowski-opensource added the action: merge The PR is ready for merge by the caretaker label Dec 13, 2022
@ngbot
Copy link

ngbot bot commented Dec 13, 2022

I see that you just added the action: merge label, but the following checks are still failing:
    failure status "google-internal-tests" is failing
    pending status "mergeability" is pending

If you want your PR to be merged, it has to pass all the CI checks.

If you can't get the PR to a green state due to flakes or broken main, please try rebasing to main and/or restarting the CI job. If that fails and you believe that the issue is not due to your change, please contact the caretaker and ask for help.

@jessicajaniuk
Copy link
Contributor

This PR was merged into the repository by commit f58ad86.

crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Jan 12, 2023
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@angular/animations](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fanimations/15.0.4/15.1.0) |
| [@angular/common](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fcommon/15.0.4/15.1.0) |
| [@angular/compiler](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fcompiler/15.0.4/15.1.0) |
| [@angular/compiler-cli](https://github.com/angular/angular/tree/main/packages/compiler-cli) ([source](https://github.com/angular/angular)) | devDependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fcompiler-cli/15.0.4/15.1.0) |
| [@angular/core](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fcore/15.0.4/15.1.0) |
| [@angular/forms](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fforms/15.0.4/15.1.0) |
| [@angular/platform-browser](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser/15.0.4/15.1.0) |
| [@angular/platform-browser-dynamic](https://github.com/angular/angular) | dependencies | minor | [`15.0.4` -> `15.1.0`](https://renovatebot.com/diffs/npm/@angular%2fplatform-browser-dynamic/15.0.4/15.1.0) |

---

### Release Notes

<details>
<summary>angular/angular</summary>

### [`v15.1.0`](https://github.com/angular/angular/blob/HEAD/CHANGELOG.md#&#8203;1510-2023-01-10)

[Compare Source](angular/angular@15.0.4...15.1.0)

#### Deprecations

##### router

-   CanLoad guards in the Router are deprecated. Use CanMatch
    instead.
-   router writable properties

    The following strategies are meant to be configured by registering the
    application strategy in DI via the `providers` in the root `NgModule` or
    `bootstrapApplication`:

    -   `routeReuseStrategy`
    -   `titleStrategy`
    -   `urlHandlingStrategy`

    The following options are meant to be configured using the options
    available in `RouterModule.forRoot` or `provideRouter`.

    -   `onSameUrlNavigation`
    -   `paramsInheritanceStrategy`
    -   `urlUpdateStrategy`
    -   `canceledNavigationResolution`

    The following options are available in `RouterModule.forRoot` but not
    available in `provideRouter`:

    -   `malformedUriErrorHandler` - This was found to not be used anywhere
        internally.
    -   `errorHandler` - Developers can instead subscribe to `Router.events`
        and filter for `NavigationError`.

##### common

| Commit | Type | Description |
| -- | -- | -- |
| [fe50813664](angular/angular@fe50813) | feat | Add BrowserPlatformLocation to the public API ([#&#8203;48488](angular/angular#48488)) |
| [2f4f0638c7](angular/angular@2f4f063) | fix | Add data attribtue to NgOptimizedImage ([#&#8203;48497](angular/angular#48497)) |

##### compiler

| Commit | Type | Description |
| -- | -- | -- |
| [a532d71975](angular/angular@a532d71) | feat | allow self-closing tags on custom elements ([#&#8203;48535](angular/angular#48535)) |
| [caf7228f8a](angular/angular@caf7228) | fix | resolve deprecation warning ([#&#8203;48652](angular/angular#48652)) |
| [33f35b04ef](angular/angular@33f35b0) | fix | type-only symbols incorrectly retained when downlevelling custom decorators ([#&#8203;48638](angular/angular#48638)) |

##### compiler-cli

| Commit | Type | Description |
| -- | -- | -- |
| [caedef0f5b](angular/angular@caedef0) | fix | update `@babel/core` dependency and lock version ([#&#8203;48634](angular/angular#48634)) |

##### core

| Commit | Type | Description |
| -- | -- | -- |
| [6acae1477a](angular/angular@6acae14) | feat | Add `TestBed.runInInjectionContext` to help test functions which use `inject` ([#&#8203;47955](angular/angular#47955)) |
| [38421578a2](angular/angular@3842157) | feat | Make the `isStandalone()` function available in public API ([#&#8203;48114](angular/angular#48114)) |
| [dd42974b07](angular/angular@dd42974) | feat | support TypeScript 4.9 ([#&#8203;48005](angular/angular#48005)) |

##### forms

| Commit | Type | Description |
| -- | -- | -- |
| [8aa8b4b77c](angular/angular@8aa8b4b) | fix | Form provider FormsModule.withConfig return a FormsModule ([#&#8203;48526](angular/angular#48526)) |

##### language-service

| Commit | Type | Description |
| -- | -- | -- |
| [5f0b53c735](angular/angular@5f0b53c) | feat | Allow auto-imports to suggest multiple possible imports. ([#&#8203;47787](angular/angular#47787)) |
| [6a8ea29a04](angular/angular@6a8ea29) | fix | expose `package.json` for vscode extension resolution ([#&#8203;48678](angular/angular#48678)) |
| [ce8160ecb2](angular/angular@ce8160e) | fix | Prevent crashes on unemitable references ([#&#8203;47938](angular/angular#47938)) |
| [e615b598ba](angular/angular@e615b59) | fix | ship `/api` entry-point ([#&#8203;48670](angular/angular#48670)) |
| [6ce7d76a0e](angular/angular@6ce7d76) | fix | update packages/language-service/build.sh script to work with vscode-ng-language-service's new Bazel build ([#&#8203;48663](angular/angular#48663)) |

##### localize

| Commit | Type | Description |
| -- | -- | -- |
| [a1a8e91eca](angular/angular@a1a8e91) | fix | add triple slash type reference on `@angular/localize` on \`ng  add ([#&#8203;48502](angular/angular#48502)) |

##### migrations

| Commit | Type | Description |
| -- | -- | -- |
| [cc284afbbc](angular/angular@cc284af) | fix | combine newly-added imports in import manager ([#&#8203;48620](angular/angular#48620)) |

##### router

| Commit | Type | Description |
| -- | -- | -- |
| [228e992db7](angular/angular@228e992) | docs | Deprecate canLoad guards in favor of canMatch ([#&#8203;48180](angular/angular#48180)) |
| [0a8b8a66cd](angular/angular@0a8b8a6) | docs | Deprecate public members of Router that are meant to be configured elsewhere ([#&#8203;48006](angular/angular#48006)) |
| [332461bd0c](angular/angular@332461b) | feat | Add ability to override `onSameUrlNavigation` default per-navigation ([#&#8203;48050](angular/angular#48050)) |
| [f58ad86e51](angular/angular@f58ad86) | feat | Add feature provider for enabling hash navigation ([#&#8203;48301](angular/angular#48301)) |
| [73f03ad2d2](angular/angular@73f03ad) | feat | Add new NavigationSkipped event for ignored navigations ([#&#8203;48024](angular/angular#48024)) |
| [3fe75710d9](angular/angular@3fe7571) | fix | page refresh should not destroy history state ([#&#8203;48540](angular/angular#48540)) |

#### Special Thanks

Alan Agius, Alex Castle, Alex Rickabaugh, Andrew Kushnir, Andrew Scott, Bob Watson, Charles Lyding, Derek Cormier, Doug Parker, Dylan Hunn, George Kalpakas, Greg Magolan, Jessica Janiuk, JiaLiPassion, Joey Perrott, Kristiyan Kostadinov, Matthieu Riegler, Paul Gschwendtner, Pawel Kozlowski, Renan Ferro, Tim Gates, Vadim, Virginia Dooley, ced, mgechev, piyush132000, robertIsaac and sr5434

<!-- CHANGELOG SPLIT MARKER -->

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC45Ny41IiwidXBkYXRlZEluVmVyIjoiMzQuOTkuMiJ9-->

Co-authored-by: cabr2-bot <[email protected]>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1719
Reviewed-by: Epsilon_02 <[email protected]>
Co-authored-by: Calciumdibromid Bot <[email protected]>
Co-committed-by: Calciumdibromid Bot <[email protected]>
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jan 13, 2023
trekladyone pushed a commit to trekladyone/angular that referenced this pull request Feb 1, 2023
…lar#48301)

The argument against this feature:

Firstly, this isn't a navigation strategy that's very commonly desired.
Secondly, the hash strategy is a location configuration in `@angular/common`
and you can use it outside of the Router or with any custom router implementations.
So while the net effect of using the router is that it updates the URL which is
controlled by the strategy, this feature provider doesn't necessarily need to
exist in the Router. The location strategy is an application-wide configuration
and affects anything that imports `Location`.  Of course, the Router does this
in a few places but plenty of other things might as well.

The argument for this feature:

* Discoverability. While `LocationStrategy` is technically in `@angular/common`, the most
  common use-case _is_ when using it with the Router.
* Precedence in the `RouterModule.forRoot([], {useHash: true})`
* Precedence in other routing libraries (`createWebHashHistory` in VueJS
  and `HashRouter` in React, for example)
* The implementation of `withHashLocation` is much more clear than
  `useHash` was. You can look at the function and see that all it's
  doing is adding the `HashLocationStrategy` to the providers list.

resolves angular#48295 / angular#47986

PR Close angular#48301
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker area: router detected: feature PR contains a feature commit feature Issue that requests a new feature target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provideRouter: there is no option for useHash or errorHandler
4 participants