Commit graph

29561 commits

Author SHA1 Message Date
Kara Erickson
1ca2ce19ab fix(common): remove default for image width (#47082)
Previously NgOptimizedImage would default to requesting
an image at the width matching the width attribute in
the image HTML. While this works for width attrs that
match the intrinsic size of the image (e.g. responsive
images or images sized with CSS), this can be a sharp
edge for developers who use the width/height attributes
to set rendered size (i.e. instead of CSS, which one can
do for a fixed size image). In this case, defaulting to
the width attribute for the requested image would mean
requesting always at 1x quality, so screens with a DPR
 of 2+ get an image that is too small. Without a default
request width, the image served by the CDN would likely
be at intrinsic size, so 2x images would look correct.

This PR also updates the NgOptimizedImage sandbox and tests.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
0c8eb8bc82 perf(common): monitor LCP only for images without priority attribute (#47082)
This commit optimizes the logic that monitors whether a give image is an LCP element. If an image has the `priority` attribute set, there is no need to include it into monitoring. Also, if we already warned about a particular image (via a `console.warn`) - there is no need to warn again later (to avoid spamming a console).

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
37e3a6050b test(common): add e2e tests for LCP check logic of the NgOptimizedImage directive (#47082)
This commit adds e2e tests for the LCP check logic. Those tests are needed to verify the behavior in a real browser (vs relying on a Node environment).

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
d3c3426aa4 feat(common): detect LCP images in NgOptimizedImage and assert if priority is set (#47082)
This commit adds extra logic into the `NgOptimizedImage` experimental directive to detect an LCP image and assert whether the `priority` attribute is applied.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
1c065403a2 test(common): configure e2e testing infrastructure for NgOptimizedImage test app (#47082)
This commit adds the necessary e2e testing infrastructure to the `NgOptimizedImage` test app, so that the test coverage can be extended and extra scenarios can be tested in a browser.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
f8b39b087f refactor(common): move NgOptimizedImage logic that sets src to a different hook (#47082)
Currently, the logic that sets the `src` on the host `<img>` element is located in the `ngOnChanges` lifecycle hook and guarded by the dev-mode checks that the inputs do not change. However, those checks would be tree-shaken in prod mode and the `src` would be set each time the `ngOnChanges` hook is invoked. This is undesirable and may potentially lead to performance issues.

This commit moves the `src`-related logic to the `ngOnInit` hook instead, which would have the same effect (executed only once, after all inputs are set) and would behave consistently in dev and prod modes.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
4a01b204d3 refactor(common): throw an error if width or height inputs are missing or invalid (#47082)
This commit updates the `NgOptimizeImage` directive to add asserts to make sure the `width` and `height` inputs are set and have correct values (numbers only).

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
2e0d09354f refactor(common): throw an error if NgOptimizeImage inputs change (#47082)
This commit updates the `NgOptimizeImage` directive to add asserts to make sure no inputs are changed after directive initialization.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
c2854e8ef6 refactor(common): mark experimental NgOptimizedImage directive as standalone (#47082)
This commit updates the `NgOptimizedImage` directive as standalone, so it's easier to import it in
 an app (without importing any NgModules). The `NgOptimizedImageModule` is removed as no longer needed.

PR Close #47082
2022-08-16 17:36:52 +00:00
Andrew Kushnir
801daf82d1 fix(common): detect data: and blob: inputs in NgOptimizedImage directive (#47082)
This commit updates the `NgOptimizedImage` directive to throw an error when `data:` and `blob:` inputs are used.

PR Close #47082
2022-08-16 17:36:52 +00:00
Katie Hempenius
0566205a02 feat(common): Add image lazy loading and fetchpriority (#47082)
PR Close #47082
2022-08-16 17:36:51 +00:00
Andrew Kushnir
b58454d129 refactor(common): rename NgOptimizedImage directive selector (#47082)
This commit changes the `NgOptimizedImage` directive selector from `raw-src` to `rawSrc` to better align with the styleguide.

PR Close #47082
2022-08-16 17:36:51 +00:00
Andrew Kushnir
caccb125e6 refactor(common): drop the loader input in favor of IMAGE_LOADER token (#47082)
This commit updates the `NgOptimizedImage` directive to drop the `loader` input. Component-specific loaders can still be configured via `IMAGE_LOADER` token and the `loader` input was only useful in case different loaders have to be present in a single template, which doesn't seem to be a common case. We'll be able to re-introduce the input later if needed.

PR Close #47082
2022-08-16 17:36:51 +00:00
Kara Erickson
c0d407fccc refactor(common): change name of directive from NgImage => NgOptimizedImage (#47082)
We want it to be clear what benefits the image directive
confers over a normal <img> tag, and the `NgImage` name
didn't provide much information. `NgOptimizedImage` makes
it obvious that the new directive is intended to improve
performance.

PR Close #47082
2022-08-16 17:36:51 +00:00
Andrew Kushnir
1a05570fe6 test(common): add a test app for the NgImage directive (#47082)
This commit adds a simple app that uses the `NgImage` directive to simplify further investigation and tests.

PR Close #47082
2022-08-16 17:36:51 +00:00
Andrew Kushnir
0d330d0bcd refactor(common): expose NgImage directive via a private API (#47082)
This commit exports experimental `NgImage` directive via a private API of the `@angular/common` package, so that it can be used acorss other Angular packages for testing purposes.

PR Close #47082
2022-08-16 17:36:51 +00:00
Andrew Kushnir
86e77a5d55 feat(common): add Image directive skeleton (#45627) (#47082)
This commit adds Image directive skeleton as well as a set of basic tests.

PR Close #47082
2022-08-16 17:36:51 +00:00
Kristiyan Kostadinov
31429eaccc feat(core): support TypeScript 4.8 (#47038)
Adds support for TypeScript 4.8 and resolves some issues that came up as a result of the update.

Most of the issues came from some changes in TypeScript where the `decorators` and `modifiers` properties were removed from most node types, and were combined into a single `modifiers` array. Since we need to continue supporting TS 4.6 and 4.7 until v15, I ended up creating a new `ngtsc/ts_compatibility` directory to make it easier to reuse the new backwards-compatible code.

PR Close #47038
2022-08-16 16:02:47 +00:00
Andrew Scott
75df404467 feat(router): Create APIs for using Router without RouterModule (#47010)
This commit creates and exposes the APIs required to use the Angular Router without importing `RouterModule`.

The newly added APIs are tree-shakable and you can add features using special functions rather than using `ExtraOptions` to control the providers via an internal switch in Router code.

```
const appRoutes: Routes = [];
bootstrapApplication(AppComponent,
  {
    providers: [
      provideRouter(appRoutes,
        withDebugTracing(),     // enables debug tracing feature
        withInMemoryScrolling() // enables scrolling feature
    ]
  }
);
```

This "features" pattern allows for router behavior to evolve in a backwards compatible and tree-shakable way in the future. This approach also makes features more discoverable.

The newly added APIs can be used in any application today (doesn't require an application to be bootstrapped using standalone-based APIs).

Note: APIs added in this commit are released in the "Developer Preview" mode, read more about this mode in Angular docs: https://angular.io/guide/releases#developer-preview

PR Close #47010
2022-08-15 15:58:00 -07:00
George Kalpakas
8d4bc831aa build(docs-infra): upgrade cli command docs sources to 14d4d528c (#47148)
Updating [angular#main](https://github.com/angular/angular/tree/main) from
[cli-builds#main](https://github.com/angular/cli-builds/tree/main).

##
Relevant changes in
[commit range](a764b37fa...14d4d528c):

**Modified**
- help/cache.json

PR Close #47148
2022-08-15 15:15:09 +00:00
Roman Matusevich
6277dd70d4 docs: remove duplicated styles (#47143)
PR Close #47143
2022-08-12 18:18:20 +00:00
Roman Matusevich
d4678316b4 docs: fix code samples formatting in tutorial (#47144)
PR Close #47144
2022-08-12 18:17:26 +00:00
Andrew Scott
d4f44bde50 refactor(router): Provide easily patchable file for assigning relativeLinkResolution (#47136)
For context on the migration plan, see b/241955063

PR Close #47136
2022-08-12 16:11:34 +00:00
Bob Watson
757684b705 docs: set titles to sentence case (#47083)
* update overview and reviewing topics to accommodate new ToC
* incorporate edits from peer reviews

PR Close #47083
2022-08-12 18:04:25 +02:00
Emmanuel Roux
422323cee0 feat(router): improve typings for RouterLink boolean inputs (#47101)
Add wider typings to setter of preserveFragment, skipLocationChange and replaceUrl inputs of routerLink directives and coerce them to boolean

PR Close #47101
2022-08-12 13:28:38 +00:00
Andrew Scott
93289f9c76 refactor(router): Update error message when Router is provided twice (#47130)
The current error message is absolute in that it thinks there is only
one possible way to provide Router twice. In fact, you can get a new
instance of the Router in several ways so the error message should
indicate the exact failure case with a _potential_ cause.

Based on findings in thread 0cbbd6aeec (commitcomment-80900192)

PR Close #47130
2022-08-12 13:27:49 +00:00
Bob Watson
1329707327 docs: clarify use of unsubscribe with HttpClient (#47127)
fix: #46542

PR Close #47127
2022-08-12 09:58:04 +00:00
AlirezaEbrahimkhani
5509e3512f docs: fix embedded view description issue (#46957)
createEmbeddedView method instantiates an embedded view based on this template and take your templateRef as argument and would render the passed templateRef in your ViewContainerRef.

resolves angular#46955

PR Close #46957
2022-08-11 18:07:39 +00:00
Kalbarczyk
adda3632d7 docs: add NG Poland 2022 and JS Poland 2022 to events (#47128)
PR Close #47128
2022-08-11 17:03:07 +00:00
Alma Eyre
777803c9fe docs: Moving a div down in tutorial toh-pt6.md (#47095)
PR Close #47095
2022-08-11 16:09:51 +00:00
Sonu Kapoor
8d0d6d941d docs: rename duplicate header (#47110)
PR Close #47110
2022-08-11 16:08:38 +00:00
Leosvel Pérez Espinosa
01f5598571 docs: remove duplicated sentence (#47126)
PR Close #47126
2022-08-11 16:04:15 +00:00
Dylan Hunn
64549746a5 docs: release notes for the v14.1.2 release 2022-08-10 11:10:51 -07:00
Dylan Hunn
4f7aceacda release: cut the v14.2.0-next.1 release 2022-08-10 10:55:59 -07:00
Andrew Scott
44da5a6efe build: add atscott to unavailable users (#47102)
PR Close #47102
2022-08-10 10:45:38 -07:00
4javier
4e3fc7eac8 docs: clarify providers' injection in lazy loaded modules (#47094)
Addresses https://github.com/angular/angular/issues/47059
I try to keep the edit as concise as possible because adding any further
explanation would bring to much deeper info compared to the topic of the
page

Removed some convoluted info and replaced with a link to a page that
should focus on the specific aspect of the matter.
Conditional is obliged because IMHO that page should have a dedicated
paragraph explaining various ways of populating different injectors with
providers, and maybe integrating the interesting parts from the recent
created page about standalone app.
PR Close #47094
2022-08-10 10:45:03 -07:00
Andrew Scott
2a43beec15 fix(router): Fix route recognition behavior with some versions of rxjs (#47098)
Some versions of rxjs cause the algorithm used in the Router to not recognize Route configs correctly.
This commit updates the algorithm to be compatible in the same way as other code locations internally.

Context:
1160b8194f

fixes #47089

Note: This does not have a test because I was unable to identify the
version of rxjs that would cause a failure here.

PR Close #47098
2022-08-10 09:25:06 -07:00
Victor Porof
91954cf20e fix(zone.js): Fix ConsoleTask interface typo (#47090)
Signed-off-by: Victor Porof <victorporof@chromium.org>

PR Close #47090
2022-08-09 17:03:21 -07:00
Angular Robot
8546b17ade build: update github/codeql-action action to v2.1.18 (#47015)
See associated pull request for more information.

PR Close #47015
2022-08-09 10:56:00 -07:00
AntonioCardenas
e4aee2b83d docs: add antoniocardenas to GDE resources (#47033)
PR Close #47033
2022-08-09 10:02:11 -07:00
Ilia Mirkin
bedf537951 fix(common): allow null/undefined to be passed to ngStyle input (#47069)
This brings the typing of ngStyle into parity with ngClass since commit
e2ab99b95e. Should help with some strict template checking edge cases.

PR Close #47069
2022-08-09 10:01:49 -07:00
Vovch
5e15e4f0c4 docs: change "zone" to "ngZone" in an example (#47079)
Change requesting "this.zone" to "this.ngZone" in the Plotly example, as it corresponds to the name declared in the constructor.
PR Close #47079
2022-08-09 10:01:26 -07:00
JiaLiPassion
58e604ceea release: cut the zone.js-0.11.8 release (#47084)
PR Close #47084
2022-08-09 10:00:55 -07:00
Angular Robot
b59fe01c29 build: update eslint dependencies to v5.33.0 (#47087)
See associated pull request for more information.

PR Close #47087
2022-08-09 10:00:11 -07:00
Bob Watson
340fa465ce docs: add more documentation about lint messages (#47019)
Adds suggestions for how to resolve the most common messages produced by the documentation linter.

Adds links to the Proselint and other style tests to the new documentation.

Updates pullapprove and navigation.

PR Close #47019
2022-08-08 11:34:56 -07:00
onrails
ddef8e2897 docs: updated reference link to NativeScript/Angular documentation (#47063)
PR Close #47063
2022-08-08 11:34:20 -07:00
Mladen Jakovljević
621c38813f refactor: improve disabled attribute warning (#47041)
Users using the "disabled" property binding on reactive form controls would want to know how to dynamically update the disabled state of a form control when they get a console warning.

PR Close #47041
2022-08-08 11:33:52 -07:00
Eduardo Speroni
dbed2cf079 fix(core): check if transplanted views are attached to change detector (#46974)
Prevents change detection on views transplanted in OnPush components that have been detached from change detection.

PR Close #46974
2022-08-08 11:33:29 -07:00
Edward
951d02e1de docs: fix dependecy injection documentation page typos (#47057)
PR Close #47057
2022-08-08 11:33:04 -07:00
Bruno Barbosa
974a71c437 fix(docs-infra): fix nav css on tutorial tour of heroes (#47064)
Fix the navigation button to work properly by the css style applied when the button is active, on tutorial Tour of Heroes.

PR Close #47064
2022-08-08 11:32:40 -07:00