Commit graph

29561 commits

Author SHA1 Message Date
Andrew Scott
d849350c7b fix(migrations): Ensure routerLink migration doesn't update unrelated files (#43519)
The migration was previously touching files that did not have any
expressions to migrate. This change ensures that the migration doesn't
commit any updates on files that do not need them.
This change, however, does not address the underlying issue with the
migration and CRLF (which is fixed in a follow-up change).

Related to #43416

PR Close #43519
2021-09-21 18:22:39 +00:00
Renovate Bot
6ce6beb1d6 build: lock file maintenance (#43513)
PR Close #43513
2021-09-21 17:44:00 +00:00
George Kalpakas
d1baf7cdfb fix(docs-infra): add a "skip to content" link for better accessibility (#43460)
Add a link at the top of the page that allows skipping directly to the
main content area. This allows people using assistive technologies to
skip navigation-related parts of the page which are presented before the
main content.

Related resources:
- [www.w3.org](https://www.w3.org/TR/WCAG20-TECHS/G1.html)
- [accessibility.oit.ncsu.edu](https://accessibility.oit.ncsu.edu/it-accessibility-at-nc-state/developers/accessibility-handbook/mouse-and-keyboard-events/skip-to-main-content)
- [css-tricks.com](https://css-tricks.com/how-to-create-a-skip-to-content-link)

---
Example implementations on other websites:

- **[accessibility.oit.ncsu.edu](https://accessibility.oit.ncsu.edu/)**:
  ![accessibility.oit.ncsu.edu](https://user-images.githubusercontent.com/8604205/133285834-db1314e6-ff71-4862-8f80-c8a9f69083d9.png)

- **[smile.amazon.com](https://smile.amazon.com/)**:
  ![smile.amazon.com](https://user-images.githubusercontent.com/8604205/133285854-1163e733-8de3-4244-bc23-5cd5a943001d.png)

- **[chase.com](https://chase.com/)**:
  ![chase.com](https://user-images.githubusercontent.com/8604205/133293396-ade9d95f-56ce-4cdc-8926-b4cd2dc6c3a5.png)

- **[css-tricks.com](https://css-tricks.com/)**:
  ![css-tricks.com](https://user-images.githubusercontent.com/8604205/133285845-702045ee-088a-40f1-bb26-21adebb02505.png)

- **[github.com/angular/angular](https://github.com/angular/angular)**:
  ![github.com/angular/angular](https://user-images.githubusercontent.com/8604205/133921259-9fd759b9-f862-47c3-b069-643912df17a1.png)

- **[news.sky.com](https://news.sky.com/)**:
  ![news.sky.com](https://user-images.githubusercontent.com/8604205/133285863-89946096-5353-4b2b-ab69-eb748bdcfe06.png)

- **[youtube.com](https://youtube.com/)**:
  ![youtube.com](https://user-images.githubusercontent.com/8604205/133921261-a68a12c1-1aea-4ad0-8457-b4eaf8ed3497.png)

---
Angular.io implementation:

- **[angular.io](https://angular.io/)**:
  ![angular.io](https://user-images.githubusercontent.com/8604205/133409634-0054625c-d14b-4ebe-bb4c-142cfc524d98.png)

Fixes #42936

PR Close #43460
2021-09-21 16:12:39 +00:00
George Kalpakas
4dd107d18c fix(docs-infra): correctly handle in-page anchor links (#43460)
Previously, anchor links that were supposed to point to fragments inside
the current page (e.g. `href="#something"`) would end up navigating to
the homepage (`/`). This was due to them being resolved relative to the
base URL, which is set to `/` (via `<base href="/">`). See also
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base#in-page_anchors.

This commit fixes this issue by handling such links specially in
`LocationService#handleAnchorClick()` and prepending the current path to
the URL.

This will also be useful for implementing a "skip to content" link as
described in #42936.

PR Close #43460
2021-09-21 16:12:39 +00:00
George Kalpakas
235e4aaa25 fix(docs-infra): focus elements when scrolling to them (if focusable) (#43460)
When using `ScrollService#scrollToElement()` to scroll to a specific
element, also focus the element if it is focusable (i.e. if it has a
`focus()` method).

This will be useful for implementing a "skip to content" link as
described in #42936.

PR Close #43460
2021-09-21 16:12:39 +00:00
George Kalpakas
0e2ff28627 fix(docs-infra): improve accessibility of contributor cards (#43460)
Improve the accessibility of contributor cards (in `/about`) by making
them easier to navigate via keyboard:

- Show the (otherwise hidden) contributor info links on focus.
- Make the "View bio" link focusable via keyboard (to give a clearer
  indication that users can click to view the bio - although technically
  the click is handled by an ancestor).
- Make the flipped cards focusable via keyboard (so it is possible to
  click them to unflip).

PR Close #43460
2021-09-21 16:12:39 +00:00
George Kalpakas
a072c96305 fix(docs-infra): improve accessibility of button groups (#43460)
Improve the accessibility of button groups (such as those seen in
`/about` and `/resources` to choose between the different categories)
by making them easier to navigate via keyboard:

- Make the individual buttons focusable via keyboard.
  (Previously, they were not focusable - despite being anchor elements,
  because they were lacking an `href` attribute.)

- Give focused buttons a different style.

PR Close #43460
2021-09-21 16:12:39 +00:00
Renovate Bot
0a57e3155d build(devtools): update angular-cli to 86bed50 2021-09-21 06:58:52 -07:00
Teri Glover
7d6ba72b90 docs: Edits to remove jargon (#42928)
PR Close #42928
2021-09-20 22:50:58 +00:00
Teri Glover
bba683bb68 docs: Edits to remove jargon (#42918)
PR Close #42918
2021-09-20 22:50:15 +00:00
Teri Glover
6ba6bdf768 docs: Edits to remove jargon (#42912)
PR Close #42912
2021-09-20 22:49:26 +00:00
Kristiyan Kostadinov
df792ebc26 fix(common): titlecase pipe incorrectly handling numbers (#43476)
Fixes that the `titlecase` pipe wasn't picking up numbers which meant that cases like `1st` would be tranformed to `1St`.

Fixes #43459.

PR Close #43476
2021-09-20 21:56:45 +00:00
Andrew Scott
c5d0bd4966 fix(router): Prevent URL flicker when new navigations cancel ongoing ones (#43496)
This bit of code is problematic for several reasons:
1. AngularJS-specific handling should not exist in core router code if it can be avoided.
It's not something that should complicated the code long-term
2. It causes URL flickering (the `replace: /` really does happen and can be observed)
3. The original intent was likely for the URL to not actually change;
since the Router only initially supported 'deferred' navigations, this would _usually_ be the case.
4. It actually causes observers of URL changes more problems in handling changes
because the router is already about to process another navigation request.
Notice that when using `'computed'` restoration logic, we do not reset the URL
because it would cause another location change event and conflict with the new navigation.
5. It only resets the browser URL but does nothing to sync the rest of the internal state of the router.
6. It makes guards which call `router.navigate()` behave _slightly_ differently
than guard which return `UrlTree`. Guards which return `UrlTree` do not reset the
URL, but instead just trigger a new navigation.
7. It resets the entire URL rather than just the portion that the
   `UrlHandlingStrategy` is configured to handle. Theoretically, the
   Router could be configured to only handle a part of the URL so failed
   navigations should not reset parts it is not configured to touch.
   Note that this is actually a problem in other places in the router as
   well where `resetState` is not called before
   `resetUrlToCurrentUrlTree`.

As a nice benefit, when `urlUpdateStrategy` is set to `'eager'`, this
makes #17004 possible.

BREAKING CHANGE:
The router will no longer replace the browser URL when a new navigation
cancels an ongoing navigation. This often causes URL flicker and was
only in place to support some AngularJS hybrid applications. Hybrid
applications which rely on the `navigationId` being present on initial
navigations that were handled by the Angular router should instead
subscribe to `NavigationCancel` events and perform the
`location.replaceState` themselves to add `navigationId` to the Router
state.
In addition, tests which assert `urlChanges` on the `SpyLocation` may
need to be adjusted to account for the `replaceState` which is no longer
triggered.

PR Close #43496
2021-09-20 20:57:57 +00:00
JoostK
9470f56ad3 fix(compiler-cli): handle directives that refer to a namespaced class in a type parameter bound (#43511)
The template type-checker has to emit type constructors for the
directives that are used in a template, where a type constructor's
declaration has to mirror the type parameter constraints as they were
originally declared. Therefore, the compiler analyzes whether a type
parameter constraint can be recreated, e.g. by generating imports for
any type references. Some type references cannot be recreated, in which
case the compiler has to fall back to a strategy where the type
constructor is created inline in the original source file (which comes
with a performance penalty).

There used to be an issue for type references to namespaced declarations.
The compiler is unable to emit such references such that an inline
type constructor should be used as fallback, but this did not happen.
This caused the attempt to emit the type reference to fail, as the
namespaced declaration cannot be located by the reference emitters.

This commit fixes the issue by using a stricter check to determine if a
type parameter requires an inline type constructor. The TypeScript
reflection host's `isStaticallyExported` logic was expanded to work for
any declaration instead of just classes, as e.g. type declarations can
also be referenced in a type parameter constraint.

Closes #43383

PR Close #43511
2021-09-20 19:56:31 +00:00
Virginia Dooley
e41a583c40 docs: reviewed tag added (#43493)
PR Close #43493
2021-09-20 17:09:50 +00:00
Virginia Dooley
5f86650789 docs: reviewed tag added (#43490)
PR Close #43490
2021-09-20 17:09:20 +00:00
Kristiyan Kostadinov
258b472aa5 docs: fix graphic in safari (#43502)
Fixes that the "Loved by millions" graphic doesn't look correctly on Safari.

Note that this fix is somewhat repetitive, but I couldn't find a better one. These are the other things I tried:
* Setting units on the size of `#angular-logo`.
* Setting the size of `#angular-logo` inside the `style` tag.
* Setting the size with inline styles.

Fixes #43498.

PR Close #43502
2021-09-20 17:07:10 +00:00
Renovate Bot
6e1df45b41 build(devtools): update angular-cli to b2b499f 2021-09-20 09:55:45 -07:00
dario-piotrowicz
80f5a4e7fb fix(docs-infra): improve aio contributors page responsiveness (#43355)
Improve the aio contributors page responsiveness regarding the browser's
font-size so that the page looks good regarding on font-size settings
(no cropped or cramped content)

PR Close #43355
2021-09-20 16:02:24 +00:00
Renovate Bot
02ea28308f build(devtools): update angular-framework to ea0af7a 2021-09-19 14:04:30 -07:00
Virginia Dooley
91183eb142 docs: reviewed tag added (#43492)
PR Close #43492
2021-09-17 18:46:08 +00:00
Renovate Bot
e33e649e82 build(devtools): update angular-cli to bcf52c0 2021-09-17 11:39:19 -07:00
Virginia Dooley
046b35f701 docs: review tag added (#43471)
PR Close #43471
2021-09-17 18:35:42 +00:00
Teri Glover
3d090ba74d docs: Edits to remove jargon (#42986)
PR Close #42986
2021-09-17 18:35:10 +00:00
Teri Glover
33708f256d docs: Edits to remove jargon (#43017)
PR Close #43017
2021-09-17 18:10:40 +00:00
Virginia Dooley
cabbff6f92 docs: reviewed tag added (#43491)
PR Close #43491
2021-09-17 17:57:55 +00:00
Mwiku
928e1e2275 docs: describe your change... (#43455)
Use the --defaults option when creating the application to make CSS the default styling processor.
PR Close #43455
2021-09-17 17:54:24 +00:00
Renovate Bot
8570163c26 build(devtools): update dependency webpack to v5.53.0 2021-09-17 10:38:46 -07:00
Renovate Bot
4d7e383f69 build(devtools): update angular-framework to a2c96f5 2021-09-17 10:38:21 -07:00
Pei Wang
916487a873 build: Auto-gen tsec tsconfig files (#43440)
Previously, tsec-related tsconfig.json files are manually managed.
Switch to automatically generated ones.

PR Close #43440
2021-09-17 17:17:34 +00:00
Teri Glover
312e421ff3 docs: Edits to remove jargon (#43045)
PR Close #43045
2021-09-17 16:39:19 +00:00
Teri Glover
313ea92534 docs: Edits to remove jargon (#42999)
PR Close #42999
2021-09-17 16:07:03 +00:00
Virginia Dooley
b040e78e0a docs: reviewed tag added (#43479)
PR Close #43479
2021-09-17 01:32:54 +00:00
Renovate Bot
47b0ea8b89 build(devtools): update angular-framework to cf69793 2021-09-16 13:02:15 -07:00
Andrew Scott
79700822fd refactor(router): remove unnecessary getTransition function (#43436)
The getTransition helper function ensures that urlAfterRedirects is assigned for when
the router does not process the previous or current URL. In this case, we would set
the browserUrlTree to be the urlAfterRedirects, which was initialized to be the browserUrlTree.
This is a no-op, so there's no need for the getTransition function at all.

PR Close #43436
2021-09-16 19:20:57 +00:00
Pete Bacon Darwin
e55d052133 test(compiler): add a test for parsing multiline expressions in attributes (#43132)
This tests a scenario that was failing in an internal project.

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
2af9ac93d4 refactor(compiler): define interfaces for each lexer token (#43132)
These token interfaces will make it easier to reason about tokens in the
parser and in specs.

Previously, it was never clear what items could appear in the `parts`
array of a token given a particular `TokenType`. Now, each token interface
declares a labelled tuple for the parts, which helps to document the token
better.

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
feba4d2719 fix(compiler): include leading whitespace in source-spans of i18n messages (#43132)
Previously, the way templates were tokenized meant that we lost information
about the location of interpolations if the template contained encoded HTML
entities. This meant that the mapping back to the source interpolated strings
could be offset incorrectly.

Also, the source-span assigned to an i18n message did not include leading
whitespace. This confused the output source-mappings so that the first text
nodes of the message stopped at the first non-whitespace character.

This commit makes use of the previous refactorings, where more fine grain
information was provided in text tokens, to enable the parser to identify
the location of the interpolations in the original source more accurately.

Fixes #41034

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
a5daa06a7f test(compiler): check fullStart source-span (#43132)
The tests were checking that the source-span of parsed HTML nodes were
accurate, but they were not checking the span when it includes the
"leading trivia", which are given by the `fullStart` rather than `start`
location.

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
d00f2345a9 refactor(compiler): expose token parts in Text nodes (#43132)
When it was tokenized, text content is split into parts that can include
interpolations and encoded entities tokens.

To make this information available to downstream processing, this commit
adds these tokens to the `Text` AST nodes, with suitable processing.

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
663f40ab81 refactor(compiler): support encoded entity tokens when lexing markup (#43132)
The lexer now splits encoded entity tokens out from text and attribute value tokens.

Previously encoded entities would be decoded and the decoded value would be
included as part of the text token of the surrounding text. Now the entities
have their own tokens. There are two scenarios: text and attribute values.

Previously the contents of `<div>Hello &amp; goodbye</div>` would be a single
TEXT token. Now it will be three tokens:

```
TEXT: "Hello "
ENCODED_ENTITY: "&", "&amp;"
TEXT: " goodbye"
```

Previously the attribute value in `<div title="Hello &amp; goodbye">` would be
a single text token. Now it will be three tokens:

```
ATTR_VALUE_TEXT: "Hello "
ENCODED_ENTITY: "&", "&amp;"
ATTR_VALUE_TEXT: " goodbye"
```

- ENCODED_ENTITY tokens have two parts: "decoded" and "encoded".
- ENCODED_ENTITY tokens are always preceded and followed by either TEXT tokens
  or ATTR_VALUE_TEXT tokens, depending upon the context, even if they represent
  an empty string.

The HTML parser has been modified to recombine these tokens to allow this
refactoring to have limited effect in this commit. Further refactorings
to use these new tokens will follow in subsequent commits.

PR Close #43132
2021-09-16 18:15:51 +00:00
Pete Bacon Darwin
8f565a2bcd refactor(compiler): support interpolation tokens when lexing markup (#43132)
The lexer now splits interpolation tokens out from text tokens.

Previously the contents of `<div>Hello, {{ name}}<div>` would be a single
text token. Now it will be three tokens:

```
TEXT: "Hello, "
INTERPOLATION: "{{", " name", "}}"
TEXT: ""
```

- INTERPOLATION tokens have three parts, "start marker", "expression"
  and "end marker".
- INTERPOLATION tokens are always preceded and followed by TEXT tokens,
  even if they represent an empty string.

The HTML parser has been modified to recombine these tokens to allow this
refactoring to have limited effect in this commit. Further refactorings
to use these new tokens will follow in subsequent commits.

PR Close #43132
2021-09-16 18:15:51 +00:00
George Kalpakas
2292a9cbd9 refactor(compiler): improve regular expression for stripping comments (#43456)
Previously, the regular expression used by the compiler's ShadowDOM CSS
shim to strip comments from CSS text was susceptible to [catastrophic
backtracking][1], which could lead to exponential (O(2^n)) increase in
complexity/execution time. More specifically, this would be triggered if
the processed text contained an unterminated comment with lots of
leading whitespace (i.e. `/*`, followed by lots of whitespace characters
and no closing `*/`).

Although such input is unlikely in real-world scenarios, this commit
improves the regular expression to not be susceptible to this issue.

[1]: https://www.regular-expressions.info/catastrophic.html

PR Close #43456
2021-09-16 16:50:49 +00:00
Pete Bacon Darwin
7efa47075c docs: remove http example dependency on 3rd party service (#43475)
Previously the `http` example did accessed the npmsearch.com website to demonstrate response caching.
But if this service became unavailable then the example (and its e2e tests) would fail.

This commit changes the example to use the in-memory-web-api for this lookup, which will not be affected by 3rd party outages.

The guide that references this example has been updated to avoid references to the original npm search service.

PR Close #43475
2021-09-16 15:59:05 +00:00
Teri Glover
18dc2a9be0 docs: Edits to remove jargon (#43067)
PR Close #43067
2021-09-15 22:53:14 +00:00
Teri Glover
b104142b59 docs: Edits to remove jargon (#43052)
PR Close #43052
2021-09-15 22:49:48 +00:00
Virginia Dooley
95a1758c72 docs: review tag added (#43466)
PR Close #43466
2021-09-15 21:44:18 +00:00
kirjs
35725f5550 fix(platform-browser): improve error message for missing animation trigger (#41356)
There are two reasons why this error can be called, but only one was covered before.

Fixes #15581

PR Close #41356
2021-09-15 21:09:21 +00:00
Virginia Dooley
e5d08c1902 docs: update reviewed tag (#43452)
PR Close #43452
2021-09-15 10:49:05 -07:00
dario-piotrowicz
66c6dbdc79 refactor(docs-infra): introduce max-len 120 eslint rule (#43439)
add the max-len rule to the aio eslintrc and fix what code
breaks such rule

PR Close #43439
2021-09-15 10:47:35 -07:00