9010 Commits

Author SHA1 Message Date
Alex Castle 37bbc61cfe feat(common): Backport NgOptimizedImage to Angular 14.
Add files and tests from Angular 15 NgOptimizedImage to Angular 14 as a special project by Chrome Aurora
2023-03-08 17:31:31 +01:00
Andrew Kushnir 244a7d2d0c docs(core): add an error details page for unsafe <iframe> bindings (#48028)
PR Close #48028
2022-11-21 12:19:54 -08:00
Andrew Kushnir 54814c8e9b fix(core): hardening attribute and property binding rules for <iframe> elements (#48028)
This commit updates the logic related to the attribute and property binding rules for <iframe> elements. There is a set of <iframe> attributes that may affect the behavior of an iframe and this change enforces that these attributes are only applied as static attributes, making sure that they are taken into account while creating an <iframe>.

If Angular detects that some of the security-sensitive attributes are applied as an attribute or property binding, it throws an error message, which contains the name of an attribute that is causing the problem and the name of a Component where an iframe is located.

BREAKING CHANGE:

Existing iframe usages may have security-sensitive attributes applied as an attribute or property binding in a template or via host bindings in a directive. Such usages would require an update to ensure compliance with the new stricter rules around iframe bindings.

PR Close #48028
2022-11-21 12:19:54 -08:00
Andrew Scott aef353c143 fix(router): Ensure renavigating in component init works with enabledBlocking (#48066)
The way to complete the `Subject` in a way that is able to be read on
the subject properties itself is to call `unsubscribe`:
https://github.com/ReactiveX/rxjs/blob/afac3d574323333572987e043adcd0f8d4cff546/src/internal/Subject.ts#L101-L104
This sets the `closed` property to `true` whereas `complete` does not.

fixes #48052

PR Close #48066
2022-11-15 21:40:13 +00:00
Alan Agius a4312e1be5 fix(core): add zone.js version 0.12.x as a valid peer dependency (#48002)
This commit adds `zone.js` version `0.12.x` as a valid peer dependency

PR Close #48002
2022-11-09 09:54:11 -08:00
Andrew Scott 28efb06a96 test(router): Move test for redirect under correct describe block (#47993)
This moves a redirect test to be grouped with other redirect tests.

PR Close #47993
2022-11-08 10:34:22 -08:00
Kristiyan Kostadinov c3bc035f5d refactor(core): remove duplicate createRenderer call (#47981)
Fixes that we were calling `createRenderer` even though we had one already. This likely wasn't a performance issue since the renderer factory caches the renderer, but it's still better to reuse it to avoid confusion in the future.

Fixes #47980.

PR Close #47981
2022-11-07 12:33:24 -08:00
Albert Szekely db867fee77 fix(router): fix redirectTo on named outlets - resolves #33783 (#47927)
fix(router): fix redirectTo on named outlets - resolves #33783

PR Close #47927
2022-11-04 09:30:31 -07:00
Kristiyan Kostadinov 92d28bdd99 perf(platform-browser): resolve memory leak when using animations with shadow DOM (#47903)
`AnimationRendererFactory` maintains a map between a renderer delegate and the animations renderer it corresponds to, but the renderers are never removed from the map. This leads to memory leaks when used with the `ShadowDom` view encapsulation, because the specific renderer keeps a references to its shadow root which in turn references all the elements in the view.

These changes resolve the leak by clearing the reference when the animations renderer is destroyed.

Fixes #47892.

PR Close #47903
2022-11-01 04:46:08 -07:00
Alan Agius d2d9bbf5ce fix(platform-server): call onSerialize when state is empty (#47888)
Commit https://github.com/angular/angular/commit/a0b2d364156eed0d33831c37b00ea5c58ff4bbec#diff-3975e0ee5aa3e06ecbcd76f5fa5134612f7fd2e6802ca7d370973bd410aab55cR25-R31 changed the serialization phase logic so
that when the state is empty the script tag is not added to the document. As a side effect, this caused the `toJson` not called which caused the `onSerialize` callbacks also not to be called.
These callbacks are used to provide the value for a key when `toJson` is called. Example: https://github.com/ngrx/platform/issues/101#issuecomment-351998548

Closes #47172

PR Close #47888
2022-10-28 02:27:57 -07:00
urugator 64c8ebaf9f docs(router): fix misleading description of BaseRouteReuseStrategy (#47786)
The original description gave a false impression that only query params and fragment changes are ignored, while actually `routeParams` changes are ignored as well.
PR Close #47786
2022-10-19 20:12:23 +02:00
Alan Agius 3fd176a905 fix(compiler-cli): add missing period to error message (#47744)
With this change we add a missing period to the error message.

PR Close #47744
2022-10-12 15:57:25 +00:00
Charles Lyding c3821f5ab5 perf(compiler-cli): minimize filesystem calls when generating shims (#47682)
Previously when a file was being analyzed to determine if a shim should
be generated, up to two calls to the host `fileExists` function per file
per generator were made. In the default host, each `fileExists` call made
two underlying file system calls. Following these calls, the file was then
read via `getSourceFile`. However, `getSourceFile` will return `undefined`
if the requested file does not exist. As a result, `getSourceFile` can be
used directly to request both potential file names and leverage the return
value to determine if the file does not exist. This avoids the need to call
`fileExists` at all.

PR Close #47682
2022-10-07 09:10:35 -07:00
Álvaro Martínez 5819c8ecff docs(forms): setErrors emitEvent default value (#47546)
PR Close #47546
2022-10-06 20:24:52 +00:00
Ciprian Sauliuc 60e758a837 docs: add oxford commas and rephrase sentences (#47540)
PR Close #47540
2022-09-29 16:41:32 -07:00
Ole M 66aece3aad docs(common): update reference url to ICU docs (#47518)
PR Close #47518
2022-09-29 10:53:28 -07:00
Pawel Kozlowski ce9134ffcb test(upgrade): demonstrate that downgraded component can be standalone (#47504)
This change is adding a test demonstrating that a standalone component
can be downgraded to a AngularJS component.

PR Close #47504
2022-09-29 10:52:56 -07:00
Pawel Kozlowski ed51ecd95c test(upgrade): demonstrate that upgraded component can be standalone (#47503)
This change is adding a test demonstrating that AngularJS component
can be upgraded to a standalone directive.

PR Close #47503
2022-09-29 10:52:14 -07:00
JoostK a4b66fe1e5 perf(compiler-cli): cache source file for reporting type-checking diagnostics (#47508)
When reporting type-checking diagnostics in external templates we create a
`ts.SourceFile` of the template text, as this is needed to report Angular
template diagnostics using TypeScript's diagnostics infrastructure. Each
reported diagnostic would create its own `ts.SourceFile`, resulting in
repeatedly parsing of the template text and potentially high memory usage
if the template is large and there are many diagnostics reported. This commit
caches the parsed template in the template mapping, such that all reported
diagnostics get to reuse the same `ts.SourceFile`.

Closes #47470

PR Close #47508
2022-09-28 14:08:25 -07:00
Alan Agius 2c46b5ab24 fix(core): correctly check for typeof of undefined in ngDevMode check (#47480)
Previously, this check was wrong as typeof returns a string.

PR Close #47480
2022-09-23 14:00:46 -07:00
dario-piotrowicz bba2dae812 fix(animations): make sure that the useAnimation function delay is applied (#47468)
make sure that when an animation is used via the `useAnimation` function
and a delay has been provided then that delay gets correctly applied

(this PR is a follow up for #47285)

PR Close #47468
2022-09-20 10:10:24 +02:00
Angular Robot 1dd5b4250a build: update dependency google-closure-compiler to v20220905 (#47437)
See associated pull request for more information.

PR Close #47437
2022-09-19 17:21:03 +02:00
Andrew Kushnir e21494a333 refactor(core): drop RootContext object (#47056)
In a previous refactor, the `RootContext` was update to only contain a reference to a component. This commit perform further refactoring to get rid of the `RootContext` altogether, while storing component reference directly on the root view (without the `RootContext` wrapper).

PR Close #47056
2022-09-13 09:21:35 -07:00
dario-piotrowicz 937e6c5b3d fix(animations): make sure that the animation function delay is applied (#47285)
make sure that when an animation is defined via the `animation` function
(and used via `useAnimation`) and a delay has been provided then that
delay gets correctly applied

resolves #47283

PR Close #47285
2022-09-13 09:20:45 -07:00
Sebastian 24e5c2a83f docs(core): fix viewProviders & providers typos in NodeInjectorFactory (#47408)
Fixes incorrect spellings for providers (provides) and viewProviders (viewProvides) in NodeInjectorFactory examples
PR Close #47408
2022-09-13 09:20:18 -07:00
Andrew Kushnir bb06432948 refactor(platform-server): add a marker to specify how a page was rendered (#47103)
This commit updates the `renderApplication`, `renderModule` and `renderModuleFactory` functions to append a special marker (in a form of an attribute, called `ng-server-context`) to the component host elements. This marker is needed to analyze how a page was rendered.

PR Close #47103
2022-09-12 19:05:49 -07:00
onrails 183dbb7c44 docs(forms): correcting description verbs of formGroup methods (#47399)
Updated methods' description verbs. They are sometimes used with the assumption of the 'it' pronoun and sometimes not. For instance, the verb  'to construct' is used with 's' in one method description and not others. It is the case for other verbs as well. This is also remarkable in the description of the built-in methods of FormArray.
PR Close #47399
2022-09-12 19:05:23 -07:00
Andrew Kushnir c9bdf9bab1 fix(common): rename rawSrc -> ngSrc in NgOptimizedImage directive (#47362) (#47396)
As an ongoing effort to stabilize the NgOptimizedImage API before existing the Developer Preview, this commit renames the `rawSrc` attribute used for the NgOptimizedImage selector matching to `ngSrc`. The `rawSrcset` is also renamed to `ngSrcset` for consistency.

The motivation for this change is to align the attribute name better with other built-in directives, such as `ngFor`, `ngIf`, `ngClass`, `ngStyle`, etc.

Note: this is technically a breaking change, but since the NgOptimizedImage directive is in the Developer Preview mode, we land the change in a patch branch.

PR Close #47362

PR Close #47396
2022-09-12 01:18:55 -07:00
Andrew Kushnir a61d553d73 refactor(common): drop unnecessary srcset sanitization (#47302)
This commit updates runtime and compiler to drop unnecessary `srcset` sanitization. The sanitization was needed previously for old browsers, but all modern browsers can handle `srcset` safely without any additional sanitization.

See prior discussion in https://github.com/angular/angular/pull/45182.

Resolves #45164.

PR Close #47302
2022-09-09 14:27:16 -07:00
Kristiyan Kostadinov 80c66a1e57 fix(forms): don't prevent default behavior for forms with method="dialog" (#47308)
The forms `submit` event handlers have a `return false` to prevent form submissions from reloading the page, however this also prevents the browser behavior for forms with `method="dialog"`.

These changes add an exception since the `method="dialog"` doesn't refresh the page.

Fixes #47150.

PR Close #47308
2022-09-09 14:26:49 -07:00
Andrew Kushnir 403b970e78 refactor(common): create an NgFor alias for NgForOf directive (#47309)
This commit adds a re-export of the `NgForOf` class as `NgFor` to improve the DX for cases when the directive is used as standalone. Developers can import `NgFor` class, which better matches the `ngFor` attribute used in a template.

PR Close #47309
2022-09-09 14:04:55 -07:00
Pawel Kozlowski a3e1303f04 fix(core): imply @Optional flag when a default value is provided (#47242)
Unify default value handling across injector and node injector: as long
as a default value is provided it has the same effect as specifying the
@Optional() flag.

Fixes #47109

PR Close #47242
2022-09-08 09:34:18 -07:00
JoostK 0e35829580 fix(compiler): avoid errors for inputs with Object-builtin names (#47220)
Using raw objects as a lookup structure will inadvertently find methods defined on
`Object`, where strings are expected. This causes errors downstream when string
operations are applied on functions.

This commit switches over to use `Map`s in the DOM element schema registry to fix
this category of issues.

Fixes #46936

PR Close #47220
2022-09-06 11:55:13 -07:00
George Kalpakas 6091786696 fix(service-worker): include headers in requests for assets (#47260)
Previously, when requesting non-cached asset resources from the network,
the ServiceWorker would strip off all request metadata (including
headers). This was done in order to avoid issues with opaque responses,
but it turned out to be overly aggressive, breaking/worsening legit
usecases (such as requesting compressed data).

This commit fixes this by preserving the headers of such requests.

For reference, Workbox passes the original request as is. (See for
example the [NetworkFirst][1] strategy).

> **Note**
> Data requests (i.e. requests for URLs that belong to a data-group) are
  not affected by this. They already use the original resource as is.

[1]: https://github.com/GoogleChrome/workbox/blob/95f97a207fd51efb3f8a653f6e3e58224183a778/packages/workbox-strategies/src/NetworkFirst.ts#L90

Fixes #24227

PR Close #47260
2022-09-06 10:03:13 -07:00
George Kalpakas 65d936296d test(service-worker): simplify how redirects are defined in MockServerState (#47260)
Previously, the `MockServerStateBuilder#withRedirect()` method did two
things: (a) define a redirect from one path to another and (b) specify
the contents of the redirect destination. This was confusing, because it
deviated from the regular way of specifying file contents, which is via
a `MockFileSystem` instance.

This commit slightly simplifies the process of defining redirects by
having the `withRedirect()` method only define the redirect and let the
contents of the redirect destination be specified as usual via
`MockFileSystem`. This makes `MockFileSystem` the single source of truth
for file contents used with `MockServerState`.

PR Close #47260
2022-09-06 10:03:13 -07:00
George Kalpakas f5cfbe00df test(service-worker): fix default value of Request#credentials (omit --> same-origin) (#47260)
Previously, the default value of `MockRequest#credentials` (used in
testing) was set to `omit`. This was different than the default value
used in browsers, which is `same-origin` (see [Request docs on MDN][1])
and could lead to incorrect test results.

This commit changes the default value for `credentials` to `same-origin`
to match what would happen in the browser.

[1]: https://developer.mozilla.org/en-US/docs/Web/API/Request/credentials

PR Close #47260
2022-09-06 10:03:13 -07:00
George Kalpakas 28d33505fd fix(service-worker): only consider GET requests as navigation requests (#47263)
Previously, the criteria for determining if a request was a
[navigation request][1] did not account for the request method. This
incorrectly identified HTML form submit POST requests as navigation
requests and served `index.html` instead of passing them through to the
server, thus breaking the form submission.

This commit fixes this by ensuring that only GET requests are considered
navigation requests.

> **Note**
> HTML forms with their method set to `GET` will still be affected by
> the issue. This is not a big concern, because using `GET` for form
> submission is quite uncommon and generally discouraged (due to
> limitations and security considerations).

[1]: https://angular.io/guide/service-worker-config#handling-navigation-requests

Fixes #36368

PR Close #47263
2022-09-06 10:02:11 -07:00
Jeremy Elbourn d8cfb7cbe5 refactor(router): remove unnecesary null (#47238)
These null values are unused and unecessary. I suspect it's a remnant from when the codebase was transpiled to Dart.

PR Close #47238
2022-09-06 09:57:38 -07:00
Jeremy Elbourn f4825c7b9d refactor(common): remove unnecesary null (#47238)
These null values are unused and unecessary. I suspect it's a remnant from when the codebase was transpiled to Dart.

PR Close #47238
2022-09-06 09:57:38 -07:00
Jeremy Elbourn e6b6e89163 refactor(animations): remove unnecesary null (#47238)
These null values are unused and unecessary. I suspect it's a remnant from when the codebase was transpiled to Dart.

PR Close #47238
2022-09-06 09:57:38 -07:00
Jeremy Elbourn da7dc4670c refactor(forms): remove unnecesary null (#47238)
These null values are unused and unecessary. I suspect it's a remnant from when the codebase was transpiled to Dart.

PR Close #47238
2022-09-06 09:57:38 -07:00
jaybell 1875ce520a fix(common): use DOCUMENT token to query for preconnect links (#47353)
`PreconnectLinkChecker` checks to see if preconnect links have been added to the `<head>` element but uses `document` directly which does not exist when rendering in Angular Universal. This PR switches the `PreconnectLinkChecker` to use the `DOCUMENT` token instead so that the query works when SSR'ing

PR Close #47353
2022-09-06 09:56:27 -07:00
Kara Erickson c0d7ac9ec2 fix(common): improve formatting of image warnings (#47299)
This is a tiny fix to add paragraph breaks in
image distortion warnings to make them a bit
easier to read. With this change, the intrinsic
and rendered image sizes are printed on their
own lines instead of mid-paragraph.

PR Close #47299
2022-09-06 09:55:57 -07:00
vyom1611 921ab02b3b refactor(service-worker): refactored code to remove useless code (#47255)
- Removes useless code in `generator.ts` and `module.ts` in service-workers
- Uses inline variables to return values from functions

PR Close #47255
2022-09-06 09:15:07 -07:00
George Kalpakas 7b92f214bb docs(service-worker): improve docs related to SwUpdate APIs (#46960)
This commit improves documentation related to recently improved or
deprecated `SwUpdate` APIs in the following ways:

- Update [check-for-update.service.ts][1] to make use of the return
  value of [SwUpdate#checkForUpdate()][2].
- Update [prompt-update.service.ts][3] to not call
  [SwUpdate#activateUpdate()][4] and just reload the page.
- Update the [SwUpdate#activateUpdate()][4] API docs to explain that it
  is only useful if you want to update a client without reloading and
  that it can easily lead to version skew.
- Update [a code-snippet][5] to no longer be [hard-coded][6].

[1]: https://github.com/angular/angular/blob/9d9d05911dbd6e2f30e4c7bced0e41fd20ec4285/aio/content/examples/service-worker-getting-started/src/app/check-for-update.service.ts#L16
[2]: https://angular.io/api/service-worker/SwUpdate#checkForUpdate
[3]: https://github.com/angular/angular/blob/9d9d05911dbd6e2f30e4c7bced0e41fd20ec4285/aio/content/examples/service-worker-getting-started/src/app/prompt-update.service.ts#L15
[4]: https://angular.io/api/service-worker/SwUpdate#activateUpdate
[5]: https://github.com/angular/angular/blob/96c6139c9ab35aa6ab2330a5a79a5906d5c2e8be/packages/service-worker/src/update.ts#L44-L54
[6]: https://angular.io/guide/docs-style-guide#hard-coded-snippets

Fixes #43665

PR Close #46960
2022-09-06 09:11:58 -07:00
Daniel Ostrovsky 626340b2a6 docs(http): Update HttClient "JSON object" to "JavaScript object" (#47325)
updated all references of "JSON object" to "JavaScript object" in HttpClient `common/http/src/client.ts`

Fixes #43242

PR Close #47325
2022-09-03 11:00:44 -07:00
Giovanni Alberto Rivas af975d5bef docs(http): replace http method return description (#47322)
PR Close #47322
2022-09-01 19:14:56 -07:00
Kristiyan Kostadinov 20e1a2470b build: update to TypeScript 4.8 final (#47270) (#47278)
Bumps up to the final version of TS 4.8 and removes some workarounds.

PR Close #47270

PR Close #47278
2022-08-26 10:27:55 -07:00
Kristiyan Kostadinov 59a6fe72a0 refactor(compiler): replace most usages of getMutableClone (#47167) (#47271)
Replaces (almost) all of the usages of the deprecated `getMutableClone` function from TypeScript which has started to log deprecation warnings in version 4.8 and will likely be removed in version 5.0. The one place we have left is in the default import handling of ngtsc which will be more difficult to remove.

PR Close #47167

PR Close #47271
2022-08-26 09:44:31 -07:00
Kara Erickson c5db867ddc fix(common): remove duplicate deepForEach (#47189)
This commit removes a duplicate deepForEach
function from url.ts. It is also in the
preconnect_link_checker, where it is actually
used.

PR Close #47189
2022-08-24 12:20:58 -07:00