angular/packages
Andrew Scott 1fe759d9a4 refactor(common): Align PathLocationStrategy constructor with default factory (#46929)
When using the Angular Router, one of `APP_BASE_HREF` or a `<base>` in
the header must be provided. When _not_ using the `RouterModule`,
injecting the `LocationStrategy` will result in the
`PathLocationStrategy` being provided with a default value used in place
of `APP_BASE_HREF` that is `document?.location?.origin ?? ''`.

It can be quite surprising and annoying that once you add `RouterModule`
to the application, suddenly the `APP_BASE_HREF` must be specifically
provide something new when it could use a sensible default instead.

The current behavior (before this commit) is as follows:

* When `RouterModule` is not provided (or the dev doesn't specifically provide
  `PathLocationStrategy`): use `DOCUMENT.location?.origin ?? ''`.
  Note that the base href in the dom and `APP_BASE_HREF` are not used.
* When `RouterModule` _is_ provided:
   1. APP_BASE_HREF if defined
   2. Get base href from DOM
   3. throw if neither of the two above are defined

This commit updates this behavior to be aligned regardless of `RouterModule`
usage. The order (by default) is now:
  1. Developer provided `APP_BASE_HREF`
  2. base href from the DOM
  3. `location.origin`
  4. If none of the above exist, use `''`

This is slightly different than the behavior before. However, I believe
it is more appropriate. For the case without `RouterModule`, it would
likely be surprising that `APP_BASE_HREF` and the base href from the DOM
are ignored by default. For the case with `RouterModule`, we now have a
more sensible fallback/default when neither `APP_BASE_HREF` nor `<base>`
are defined (instead of just throwing an error).

PR Close #46929
2022-08-01 14:21:14 -07:00
..
animations fix(animations): make sure falsy values are added to _globalTimelineStyles (#46863) 2022-07-18 21:46:12 +00:00
bazel fix(bazel): allow extendedDiagnostics option to be passed in through tsconfig (#46953) 2022-08-01 09:49:14 -07:00
benchpress build: clean up references to old master branch (#45856) 2022-05-04 16:23:33 -07:00
common refactor(common): Align PathLocationStrategy constructor with default factory (#46929) 2022-08-01 14:21:14 -07:00
compiler test: update source-map tests to account for source-map breaking change (#46888) 2022-07-19 09:40:54 -07:00
compiler-cli docs: fixed typos (#47008) 2022-08-01 11:15:54 -07:00
core refactor(router): Remove unused ANALYZE_FOR_ENTRY_COMPONENTS (#46942) 2022-08-01 11:18:09 -07:00
docs docs: fix packages\docs\di\di.md (#46704) 2022-07-08 17:53:39 +00:00
elements test(elements): add a test for standalone element creation (#46475) 2022-07-18 18:20:27 +00:00
examples refactor(core): drop all .ngfactory and .ngsummary imports (#44957) 2022-02-07 15:31:49 -08:00
forms feat(forms): add FormBuilder.record() method (#46485) 2022-07-15 22:02:44 +00:00
language-service fix(compiler-cli): only consider used pipes for inline type-check requirement (#46807) 2022-07-12 21:09:18 +00:00
localize build: update babel dependencies to v7.18.9 (#46883) 2022-07-19 16:04:09 +00:00
misc/angular-in-memory-web-api build: update angular version of in-memory-web-api (#46344) 2022-06-13 17:40:09 +00:00
platform-browser feat(platform-browser): add isEmpty method to the TransferState class (#46915) 2022-07-22 09:17:47 +00:00
platform-browser-dynamic feat(bazel): speed up dev-turnaround by bundling types only when packaging (#45405) 2022-04-21 11:09:39 -07:00
platform-server feat(platform-browser): add isEmpty method to the TransferState class (#46915) 2022-07-22 09:17:47 +00:00
private/testing test: add an internal helper to populate document.head before a test (#46250) 2022-06-06 16:12:32 -07:00
router fix(router): Use correct return type for provideRoutes function (#46941) 2022-08-01 11:20:49 -07:00
service-worker test(service-worker): remove redundant ternary operator from MockRequest initialization (#46912) 2022-08-01 09:51:56 -07:00
upgrade fix(compiler): inputs/outputs incorrectly parsed in jit mode (#46813) 2022-07-13 21:26:50 +00:00
zone.js docs: fixed typos (#47008) 2022-08-01 11:15:54 -07:00
BUILD.bazel build: Auto-gen tsec tsconfig files (#43440) 2021-09-17 17:17:34 +00:00
circular-deps-test.conf.js refactor: replace deprecated String.prototype.substr() (#45397) 2022-03-24 11:48:09 -07:00
empty.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
goog.d.ts refactor(core): replace references to goog.LOCALE with goog.getLocale() (#43089) 2021-08-10 10:35:26 -07:00
license-banner.txt build: bump license year (#44590) 2022-01-04 12:05:25 -08:00
README.md docs: add doc reference to npm package readme (#33911) 2019-11-20 14:46:23 -08:00
system.d.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
tsconfig-build.json build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
tsconfig-legacy-saucelabs.json build: bundle spec files for saucelabs legacy job (#44281) 2021-11-30 11:56:04 -05:00
tsconfig-test.json build: switch devmode output to es2015 (#44505) 2022-01-05 23:20:20 +00:00
tsconfig-tsec-base.json build: update tsconfigs to use ES2020 as target and module (#43431) 2021-10-01 18:28:42 +00:00
tsconfig.json build: enable useUnknownInCatchVariables (#44679) 2022-02-01 18:17:29 +00:00
tsec-exemption.json build: Enable tsec checks for critical packages. (#43108) 2021-09-13 14:45:57 -07:00
types.d.ts build: update to jasmine 4.0 (#45558) 2022-04-11 16:25:28 +00:00

Angular

The sources for this package are in the main Angular repo. Please file issues and pull requests against that repo.

Usage information and reference details can be found in Angular documentation.

License: MIT