21885 Commits

Author SHA1 Message Date
Teri Glover ed235bdce9 docs: Edits to remove jargon (#42999)
PR Close #42999
2021-09-17 16:07:03 +00:00
Virginia Dooley 9231c5d513 docs: reviewed tag added (#43479)
PR Close #43479
2021-09-17 01:32:54 +00:00
Pete Bacon Darwin 05e1adba48 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:52 +00:00
Pete Bacon Darwin 4cbeee79dd 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:52 +00:00
Pete Bacon Darwin 9c8a1f8a71 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:52 +00:00
Pete Bacon Darwin 6c54a0a8a9 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:52 +00:00
Pete Bacon Darwin 8ed452bbe1 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:52 +00:00
Pete Bacon Darwin 50002282a6 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:52 +00:00
Pete Bacon Darwin a40297553e 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:52 +00:00
George Kalpakas b43f21bb15 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:50 +00:00
Pete Bacon Darwin a50d77c898 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 b28ddae8a8 docs: Edits to remove jargon (#43067)
PR Close #43067
2021-09-15 22:53:15 +00:00
Teri Glover c9884b612e docs: Edits to remove jargon (#43052)
PR Close #43052
2021-09-15 22:49:49 +00:00
Virginia Dooley efec149ba7 docs: review tag added (#43466)
PR Close #43466
2021-09-15 21:44:19 +00:00
kirjs adc7c56ede 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:22 +00:00
Virginia Dooley def6315a76 docs: update reviewed tag (#43452)
PR Close #43452
2021-09-15 10:49:06 -07:00
Andrew Scott afeaf1ea13 test(router): Add tests to document expected behavior (#43450)
This is a patch port of the tests from #43449

PR Close #43450
2021-09-15 10:48:15 -07:00
dario-piotrowicz 10b16d8498 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
dario-piotrowicz f08e4dba56 refactor(docs-infra): fix typos in app component (and its tests) (#43439)
fix some minor typos found in the app.component.ts and
app.component.spec.ts files

PR Close #43439
2021-09-15 10:47:35 -07:00
Pete Bacon Darwin ba80ab31f2 docs: move i18n angular.json snippets to external file (#43216)
Note that because `angular.json` is a "boilerplate" file we cannot
just add comments to the one that is actually used in the application.

Instead this commit makes a copy, which is annotated with docregions.
To ensure that this file is not ignored by the example-collector, we had to
update the `.gitignore` to not ignore this file. (This also allows the file to be
easily stored tracked in git).

PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 5f3abd257b build(docs-infra): support overriding boilerplate files in examples (#43216)
It is now possible to specify file paths in the `"boilerplate-override"`
property of `example-config.json` files to tell the example boilerplate
system to use the file in the example directory rather than overwriting the
example file with that from the boilerplate directory.

PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin d6a3078097 build(docs-infra): indent docplaster markers to the level of the docregion (#43216)
This change makes docplaster markers fit better with the surrounding code
that is being rendered.  Instead of:

```
{
  "a": 100,
// ...
  "b": 200,
// ...
}
```

you can now get

```
{
  "a": 100,
  // ...
  "b": 200,
  // ...
}
```

PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 3d2dc18f57 build(docs-infra): switch JSON examples to use inline docregion comments (#43216)
Now JSON files should be commented using

```
// #docregion
```

rather than

```
/* #docregion */
```

There are currently no JSON files with either kind of comments so this change
has no impact yet.

But when we add some examples with such comments, they will also benefit
from `// ... ` style docplasters to join docregion fragments.

PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 14f5f58fbf docs: move duplicate custom id snippets to external examples (#43216)
PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 88f5957c71 docs: move nginx and apache config blocks to external files (#43216)
PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin d25fbc3f22 build(docs-infra): support docregions in .conf files (#43216)
This commit tells the docregion parser how to process files that end in `.conf`.

PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 6461ef7a67 docs: move plural function example to external file (#43216)
PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin aca61ad1dd docs: move global locale import to external example file (#43216)
PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 5d36ceb276 docs: move shell snippets to external example files (#43216)
PR Close #43216
2021-09-15 10:46:46 -07:00
Pete Bacon Darwin 35f1d2b91e build(docs-infra): support docregions in .sh example files (#43216)
This commit tells the docregion parser how to process `.sh` files.

PR Close #43216
2021-09-15 10:46:46 -07:00
Andrew Kushnir 9b8f056604 release: cut the v12.2.6 release (#43462) 12.2.6 2021-09-15 10:26:25 -07:00
Joe Martin (Crowdstaffing) 2050b0898b docs: update grammar (#43451)
Update grammar per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) 5af9404cba docs: update grammar (#43451)
Update grammar per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) d5c58414ab docs: update link (#43451)
Update link per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) 69035dd52d docs: update punctuation (#43451)
Update punctuation per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) 1a3a87057a docs: update grammar (#43451)
Update grammar per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) 75abf868c0 docs: update spelling (#43451)
Update spelling per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Joe Martin (Crowdstaffing) f099d9c0ea docs: update capitalization (#43451)
Update capitalization per review.

PR Close #43451
2021-09-14 15:51:31 -07:00
Andrew Scott 24cf4eaa4d refactor(router): Remove TODO and slightly adjust eager browserUrlTree update (#43426)
No test was added for this case because I can't think of a test case to
write that would work.

This change updates the code for a consistent mental model of setting
the `browserUrlTree`. It's only meant to track the `UrlTree` that the
`UrlHandlingStrategy` is set to extract, not the full `rawUrl`. Notice
that everywhere else, the `browserUrlTree` is set to
`urlAfterRedirects`, which is computed based on the extracted URL, _not_
the `rawUrl`.

PR Close #43426
2021-09-14 11:11:43 -07:00
David Shevitz 2f94ac374a docs: add guidelines for localizing angular documentation (#43314)
PR Close #43314
2021-09-14 08:32:51 -07:00
George Kalpakas d2bee44951 perf(docs-infra): reduce unnecessary whitespace in API docs (#43435)
The HTML for the docs pages is generated by Dgeni based on some
[Nunjucks][1] templates.

Previously, these templates were set up in a way that introduced a lot
excess whitespace in the generated HTML, unnecessarily bloating the
corresponding JSON files that need to be downloaded in order to view a
certain docs page. This has been discussed in #28105 and was again
observed while investigating #43285.

This commit refactors some of the templates related to API docs (which
seem to be the most affected ones) to drastically reduce the amount of
excess whitespace. More specifically, the total size of all files in
`generated/docs/api/` was reduced from ~13MB to ~7MB.

Besides the reduced payload size for each API page, this change will
also reduce the amount of memory needed by the ServiceWorker to cache
the API pages that have been visited by a user.

NOTE:
The affected files are not eagerly downloaded when navigating to
angular.io. Instead, each file is downloaded individually, as soon as a
user visits the corresponding API docs page. Therefore, the impact of
this change will be relatively small for most users.

[1]: https://mozilla.github.io/nunjucks/

PR Close #43435
2021-09-14 08:29:51 -07:00
George Kalpakas 7f23958c73 build(docs-infra): update remark-html to 13.0.2 (#43435)
NOTE:
This [version][1] includes a breaking fix ([commit b0b1ba5c5][2]), which
turns sanitization on by default. Since, we don't need sanitization (the
HTML is authored by docs authors and tooling and should be safe), this
commit restores the old behavior by setting the [sanitize][3] option to
`false`.

[1]: https://github.com/remarkjs/remark-html/releases/tag/13.0.2
[2]: https://github.com/remarkjs/remark-html/commit/b0b1ba5c55a58b26bbe1ca3b6def18e95dbbd89e
[3]: https://github.com/remarkjs/remark-html#optionssanitize

PR Close #43435
2021-09-14 08:29:50 -07:00
George Kalpakas e74eac2368 build(docs-infra): update github-slugger to 1.4.0 (#43435)
NOTE:
This [version][1] includes a breaking fix ([commit af59f343d][2]). More
specifically `github-slugger` will no longer trim the text of a heading
before generating an ID and (with whitespace converted to `-`) this
results in different heading IDs:
**Before:** `<h3>  foo bar  </h3>` --> `<h3 id="foo-bar">...`
**After:** `<h3>  foo bar  </h3>` --> `<h3 id="--foo-bar--">...`

The different IDs now break some of our anchor-links, becuase
`github-slugger` is used by [rehype-slug][3], which is in turn used by
our [autolinkHeadings][4] dgeni post-processor.

To avoid the issue with broken anchor links, we update the
`renderMethodDetail()` nunjucks macro to omit excess whitespace in
headings.

[1]: https://github.com/Flet/github-slugger/releases/tag/v1.4.0
[2]: https://github.com/Flet/github-slugger/commit/af59f343dc7fe88a94a79c721fb3225a275a095d
[3]: https://github.com/rehypejs/rehype-slug
[4]: https://github.com/angular/angular/blob/75a3c778b1f7be913f0287423d40fade68ee9adc/aio/tools/transforms/angular-base-package/post-processors/autolink-headings.js#L3

PR Close #43435
2021-09-14 08:29:50 -07:00
Andrew Scott 4034f252c9 fix(router): Allow renavigating to failed URLs (#43424)
There are situations where the Router does not currently clean up failed navigations
correctly. While this is problematic on its own, we can mitigate some of
the damage by processing any URL when we get a navigation request when
the internal router state is out of sync.

Each of the added tests would fail without this change.

fixes #34795

PR Close #43424
2021-09-13 14:48:01 -07:00
Naveed Ahmed a102b27641 fix(service-worker): clear service worker cache in safety worker (#43324)
clear angular service worker cache in safety worker to ensure stale
or broken contents are not served in future requests

Fixes #43163

PR Close #43324
2021-09-13 14:34:33 -07:00
mezhik91 baf8145ee0 docs: add Dmytro Mezhenskyi to GDE resources (#43282)
PR Close #43282
2021-09-13 12:57:00 -07:00
dario-piotrowicz 52c320fda6 docs: remove unnecessary "https://angular.io/" from aio links (#43425)
PR Close #43425
2021-09-13 09:24:07 -07:00
Renovate Bot 176aa999bd build: update dependency karma to v6 (#43422)
Updates the dependency for Karma to v6. This is a patch port PR.

PR Close #43422
2021-09-13 09:23:24 -07:00
Bjarki c8179353ce fix(docs-infra): bump aio size limit (#43406)
Increase the aio size tracking limit as a result of Trusted Types
refactoring.

PR Close #43406
2021-09-10 09:24:48 -07:00
Bjarki 604965bdde build(docs-infra): enable tsec security checker (#43406)
tsec is a TypeScript compiler wrapper for restricting use of
security-sensitive DOM APIs, in particular those that could lead to XSS
or Trusted Types violations. Add it as a linter to aio to prevent future
Trusted Types regressions on angular.io.

Also introduces security_exemptions.json, which lists the known,
security-reviewed tsec security violations. New entries can only be
added to this file after a security review, in particular making sure
that the corresponding code does not cause XSS vulnerabilities or
Trusted Types violations.

PR Close #43406
2021-09-10 09:24:48 -07:00