Commit graph

29561 commits

Author SHA1 Message Date
Kristiyan Kostadinov
95dcf5fafa fix(compiler-cli): handle default imports in defer blocks (#53695)
Fixes that `@defer` blocks weren't recognizing default imports and generating the proper code for them. Default symbols need to be accessed through the `default` property in the `import` statement, rather than by their name.

PR Close #53695
2024-02-01 15:58:21 +00:00
Ezéchiel Amen AGBLA
ebbacb9d45 docs: more readable standalone importing component example (#54196)
PR Close #54196
2024-02-01 15:57:51 +00:00
Kristiyan Kostadinov
3b892e98b0 refactor(compiler): update ordering in template pipeline (#54154)
Updates the instruction ordering logic in the template pipeline.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
ec8e8ab5d5 refactor(compiler): maintain order between two-way and one-way properties (#54154)
One of the earlier commits separated one-way and two-way bindings which ended up breaking some internal targets, because it changed the assignment order. These changes bring back the old order.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
cbe6e1ffcf refactor(compiler): allow some invalid expressions in two-way bindings that previously worked by accident (#54154)
In one of the earlier commits, the logic that appends `=$event` before parsing two-way bindings was removed and some validation was added to prevent unassignable expressions from being used. This ended up being problematic, because previously the parser was incorrectly allowing some invalid expressions which users came to depend on. For example, it transformed `[(value)]="a && a.b"` to `a && (a.b = $event)`.

These changes add some special cases for the common breakages that came up during the TGP.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
cbdfc88b24 refactor(compiler): implement new two-way listener shape in pipeline (#54154)
Implements the new shape of two-way listener instructions in the template pipeline.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
4babc47b31 refactor(compiler): update two-way listener emit in definition builder (#54154)
Updates the template definition builder to emit the new format for the listener side of two-way bindings.

```js
// Before
listener("ngModelChange", function($event) {
  return ctx.name = $event;
});

// After
ɵɵtwoWayListener("ngModelChange", function($event) {
  ɵɵtwoWayBindingSet(ctx.name, $event) || (ctx.name = $event);
  return $event;
});
```

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
a436e2d5ea refactor(compiler): preserve expression in two-way listeners (#54154)
Currently the listener side two-way listeners are parsed by appending `=$event` to the raw expression. This is problematic, because:
1. It can interfere with other expressions (see #37809).
2. It can lead to confusing error messages because users will see code that they didn't write.
3. It doesn't allow us to further manipulate the expression.

These changes remove the logic that appends `=$event` to resolve the issue. There's also some new logic that checks the expression after it has been parsed to ensure that the result is an assignable expression.

Subsequent commits will update the code that emits the expression to add back the `$event` assignment where it's needed.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
e7a75d3ec2 refactor(core): introduce two-way listener instructions (#54154)
Adds the following new instructions:
* `twoWayBindingSet` - used to assign values inside of the listener side of a two-way binding. Currently a noop, but will come into play later.
* `twoWayListener` - used to bind a two-way listener. Currently calls directly into `listener`, but it may be useful in the future.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
a22d765cca refactor(compiler): update access of members in expression parser (#54154)
Currently all the members of `_ParseAST` are public, even though they're all used only within the class. This change marks them as private so that it's explicit which ones are intended to be used outside the class.

PR Close #54154
2024-02-01 14:39:32 +00:00
Kristiyan Kostadinov
ea7d1b363f refactor(compiler): implement two-way property instruction (#54154)
Reworks the compiler so that it generates a `twoWayProperty` instruction, instead of `property`, for the property side of a two-way binding. Currently the new instruction passes through to `property`, but it'll have some two-way-binding-specific logic in subsequent PRs.

PR Close #54154
2024-02-01 14:39:32 +00:00
Joey Perrott
70d0fb088e refactor(docs-infra): migrate to using docs- prefix for class names rather than adev- for shared pieces (#54188)
Updates to later version of shared docs with prefix renamed.

PR Close #54188
2024-01-31 21:49:23 +00:00
Andrew Scott
432afd1ef4 fix(core): afterRender hooks should allow updating state (#54074)
It was always the intent to have `afterRender` hooks allow updating
state, as long as those state updates specifically mark views for
(re)check. This commit delivers that behavior. Developers can now use
`afterRender` hooks to perform further updates within the same change
detection cycle rather than needing to defer this work to another round
(i.e. `queueMicrotask(() => <<updateState>>)`). This is an important
change to support migrating from the `queueMicrotask`-style deferred
updates, which are not entirely compatible with zoneless or event `NgZone` run
coalescing.

When using a microtask to update state after a render, it
doesn't work with coalescing because the render may not have happened
yet (coalescing and zoneless use `requestAnimationFrame` while the
default for `NgZone` is effectively a microtask-based change detection
scheduler). Second, when using a `microtask` _during_ change detection to defer
updates to the next cycle, this can cause updates to be split across
multiple frames with run coalescing and with zoneless (again, because of
`requestAnimationFrame`/`macrotask` change detection scheduling).

PR Close #54074
2024-01-31 20:19:06 +00:00
Andrew Scott
33e5abd4f9 refactor(core): only run checkNoChanges once per tick (#54074)
This change updates the `checkNoChanges` pass to only run once after
both view refresh and `afterRender` hooks execute rather than both
before and after the hooks. The original motivation was to specifically
ensure that the application was in a "clean state" before running the
`afterRender` hooks and ensure that `afterRender` hooks don't "fix"
`ExpressionChanged...` errors. This, however, adds to the complexity and
cost of running change detection in dev mode. Instead, the
`checkNoChanges` pass runs once we have done all render-related work and
want to ensure that the application state has been synced to the DOM
(without additional changes).

PR Close #54074
2024-01-31 20:19:06 +00:00
Andrew Scott
ecaf7ceae0 refactor(core): Do not run afterRender hooks if there is an error (#54074)
Errors during change detection are terminal and we do not generally
attempt to continue processing or recover after one occurs. This helps clean
up the `tick` implementation with respect to running `afterRender` hooks.

PR Close #54074
2024-01-31 20:19:06 +00:00
Angular Robot
989d496708 build: update cross-repo angular dependencies (#54178)
See associated pull request for more information.

PR Close #54178
2024-01-31 20:13:06 +00:00
Angular Robot
0a67085289 build: update actions/cache action to v4 (#54179)
See associated pull request for more information.

PR Close #54179
2024-01-31 19:45:54 +00:00
Jessica Janiuk
2d20c4a25b release: cut the v17.2.0-next.1 release 2024-01-31 11:29:36 -08:00
Jessica Janiuk
0465a4c5d0 docs: release notes for the v17.1.2 release 2024-01-31 11:07:39 -08:00
Ivan Zlatanov
4f7edaa478 refactor(router): RouterLink read urlTree only once (#53817)
In RouterLink, urlTree is created every time we access it, so when used we should read it only once.

PR Close #53817
2024-01-31 17:37:12 +00:00
Angular Robot
441a23cb8b build: update actions/cache digest to e12d46a (#54176)
See associated pull request for more information.

PR Close #54176
2024-01-31 17:36:28 +00:00
Angular Robot
4b11e0c15d build: update actions/checkout digest to f43a0e5 (#54177)
See associated pull request for more information.

PR Close #54177
2024-01-31 17:35:59 +00:00
Angular Robot
f5ede2ab63 build: update slackapi/slack-github-action digest to 2a8087d (#52000)
See associated pull request for more information.

PR Close #52000
2024-01-31 16:47:31 +00:00
narendherraj
318a181d8e docs: fix link missing to lazy loading module (#54113)
author narendherraj <narendherraj@gmail.com> 1706354106 +0530
committer narendherraj <narendherraj@gmail.com> 1706718969 +0530

docs: fix link missing to lazy loading module

docs: fix link missing to lazy loading module

docs: fix link missing lazy loading module updated

PR Close #54113
2024-01-31 16:45:51 +00:00
Angular Robot
1a918b397e build: update io_bazel_rules_sass digest to d970cb5 (#52388)
See associated pull request for more information.

PR Close #52388
2024-01-31 16:45:07 +00:00
Matthieu Riegler
122213d37d fix(common): The date pipe should return ISO format for week and week-year as intended in the unit test. (#53879)
ISO 8601 defines
* Monday as the first day of the week.
* week 01 is the week with the first Thursday

Therefore:
Sunday Dec 31st 2023 is the last day of the last week of the year : W52 2023.

PR Close #53879
2024-01-31 16:41:10 +00:00
Alejandro
a297012839 docs(docs-infra): add tab titles to home, playground and tutorial (#53026)
PR Close #53026
2024-01-31 16:30:49 +00:00
Paweł Kubiak
2e2e8aad9b test(docs-infra): unit tests in the reference pages (#53529)
Implementation of additional unit tests for `Reference` pages in `adev`.

PR Close #53529
2024-01-31 16:13:31 +00:00
Jared Bada
34feb4f32d docs(docs-infra): @input getter setter syntax change (#51023)
PR Close #51023
2024-01-31 16:04:04 +00:00
kabrunko-dev
b02cf14525 fix(docs-infra): sort api reference items (#54116)
Sort correctly items from angular.dev api reference secondary navigation menu

PR Close #54116
2024-01-31 15:44:23 +00:00
Elias
b9aa25ed23 docs: Fix minor grammar mistake (#54094)
PR Close #54094
2024-01-31 15:34:26 +00:00
vatsa03
d8f417bf10 docs(core): fix example sections (#54121)
PR Close #54121
2024-01-31 15:22:30 +00:00
Matthieu Riegler
4a44f73288 docs: Update docs about equality. (#54158)
Since v17, `ngSwitch` uses a strict equality.

Fixes #54156

PR Close #54158
2024-01-31 15:07:52 +00:00
arturovt
260d3ed0d9 fix(zone.js): patch Response methods returned by fetch (#50653)
This commit updates the implementation of the `fetch` patch and additionally
patches `Response` methods which return promises. These are `arrayBuffer`, `blob`,
`formData`, `json` and `text`. This fixes the issue when zone becomes stable too early
before all of the `fetch` tasks complete. Given the following code:
```ts
appRef.isStable.subscribe(console.log);
fetch(...).then(response => response.json()).then(console.log);
```
The `isStable` observer would log `false, true, false, true`. This was happening because
`json()` was returning a native promise (and not a `ZoneAwarePromise`). But calling `then`
on the native promise returns a `ZoneAwarePromise` which notifies Angular about the task
being scheduled and forces to re-calculate the `isStable` state.

Issue: #50327

PR Close #50653
2024-01-31 14:57:25 +00:00
arturovt
f87f058a69 fix(zone.js): add __Zone_ignore_on_properties to ZoneGlobalConfigurations (#50737)
This commit updates the signature of the `ZoneGlobalConfigurations` interface and adds
missing `__Zone_ignore_on_properties` property, which may be setup to ignore specific `on`
properties from being patched.

PR Close #50737
2024-01-31 14:56:57 +00:00
Matthieu Riegler
d6e4931c68 refactor(router): remove duplicate helper methods (#53762)
`isNavigationCancelingError` & `isRedirectingNavigationCancelingError` had duplicate implementations. This commit also cleans-up those functions.

PR Close #53762
2024-01-31 14:56:24 +00:00
Matthieu Riegler
e67b9a46f6 refactor(forms): Provide RadioControlRegistry in root. (#54130)
The `RadioControlRegistry` was only provided in a module, providedIn: 'root' fixes that issue.

Fixes #54117

Co-authored-by: sr5434 <118690585+sr5434@users.noreply.github.com>

PR Close #54130
2024-01-31 14:55:56 +00:00
ahmadhakeem18
6ec2f07f5d docs: focus on the respective card of the current active line while scrolling (#53733)
make the active cards have the focus while scrolling like their
respective lines in the scroll service

PR Close #53733
2024-01-30 21:27:55 +00:00
Joey Perrott
c4b880a025 refactor: migrate docs, examples, private, service worker and upgrade to prettier formatting (#54163)
Migrate formatting to prettier for docs, examples, private, service worker and upgrade from clang-format

PR Close #54163
2024-01-30 20:08:40 +00:00
Matthieu Riegler
b560e02cdf refactor(devtools): Add hydration informations (#53910)
This commit adds hydration informations to the devtools.
* List of hydrated/hydrated components
* Shows hydration overlays
* Shows hydration errors for NG0500, 501 & 502

PR Close #53910
2024-01-30 20:03:14 +00:00
Mahdi Lazraq
274a489bb5 docs: fix path to housing location css file in lesson 03 (#54106)
PR Close #54106
2024-01-30 17:50:11 +00:00
Joey Perrott
0460a9dfaf refactor: migrate common to prettier formatting (#54150)
Migrate formatting to prettier for common from clang-format

PR Close #54150
2024-01-30 16:08:07 +00:00
kabrunko-dev
f3567bbc26 refactor(common): simplify i18n plural and select pipe metadata (#53939)
Remove pure property from pipe decorator

PR Close #53939
2024-01-30 15:06:24 +00:00
kabrunko-dev
3c881acc5d refactor(common): simplify date pipe metadata (#53939)
Remove pure property from date pipe decorator

PR Close #53939
2024-01-30 15:06:24 +00:00
Payam Valadkhan
64fa5715c6 fix(compiler-cli): generating extra imports in local compilation mode when cycle is introduced (#53543)
At the moment the extra import generation in local compilation mode fails if these extra imports produce a cycle. To handle this, the cycle handling strategy is updated for local compilation, and following the behaviour in the full compilation mode, the compiler does not generate extra import if it leads to cycle and instead leave things to the runtime.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan
7e861c640e feat(compiler-cli): generate extra imports for component local dependencies in local mode (#53543)
With option `generateExtraImportsInLocalMode` set, in local mode the compiler generates extra imports for each component local dependencies. Here local dependencies means all component's dependencies within the same compilation unit.

To achieve this, the compiler performs a "local version" of its regular static analysis to find each component's deps, and these deps are used to generate extra side effect imports.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan
f6e9dbbe73 refactor(compiler-cli): run resolve phase fully for components in local mode when generateExtraImportsInLocalMode is set (#53543)
In this commit the resolve method for components is run fully when the option `generateExtraImportsInLocalMode` is set. This is because we need local component depedencies in order to generate extra imports causing by them. This requires cutting some resolve phase logics that are unnecessary in local mode, such as diagnostics.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan
6a136d1ab3 refactor(compiler-cli): run register phase in local compilation mode (#53543)
When option `generateExtraImportsInLocalMode` is set, we need to compute component local depednecies in order to generate extra imports related to them. At the same time running the register phase in general is harmless in local compilation. So we run it anyway.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan
3263df23f2 feat(compiler-cli): generate global imports in local compilation mode (#53543)
With option `generateExtraImportsInLocalMode` set in local compilation mode, the compiler generates extra side effect imports using this rule: any external module from which an identifier is imported into an NgModule will be added as side effect import to every file in the compilation unit. To illustrate this better assume the compilation unit has source files `a.ts` and `b.ts`, and:

```
// a.ts
import {SomeExternalStuff} from 'path/to/some_where';
import {SomeExternalStuff2} from 'path/to/some_where2';

...

@NgModule({imports: [SomeExternalStuff]})

```

then the extra import `import "path/to/some_where"` will be added to both `a.js` and `b.js`. Note that this is not the case for `import "path/to/some_where2"` though, since the symbol `SomeExternalStuff2` is not imported into any NgModule.

The math behind this mechanism is, in local compilation mode we cannot resolve component external dependencies fully. For example if a component in `a.ts` uses an external component defined in an external file `some_external_comp.ts` then we can generate the import to this file in `a.js`. Instead, we want to generate an import to a file that "gurantees" that `a.js` is placed after `some_external_comp.js` in the bundle. Now since the component in  `some_external_comp.ts` is used in `a.ts`, then there must be a chain of imports starting from the NgModule that declares the component in `a.ts` to the component in `some_external_comp.ts`. This chain means some file in the same compilation unit as `a.ts` should import some external NgModule which includes `some_external_comp.ts` in its transitive closure and import it to some NgModule. So by adding this import to `a.js` we ensure that the bundling will have the right order.

PR Close #53543
2024-01-30 15:05:43 +00:00
Payam Valadkhan
5feed80523 refactor(bazel): make option generateExtraImportsInLocalMode configurable (#53543)
This is to allow testing this option using bazel

PR Close #53543
2024-01-30 15:05:42 +00:00