Commit graph

4642 commits

Author SHA1 Message Date
Thomas Nguyen
aaa00b3f9c refactor(core): Add global event delegation provider (#56247)
This replaces all addEventListener calls with a stashing function,
and installs an event listener on the document body to retrieve
the stashed function;

PR Close #56247
2024-06-27 14:24:47 +00:00
Tom Wilkinson
26f97c03b4 refactor(core): Use ActionResolver in Dispatcher. (#56369) (#56369)
`EventContract` usages in Angular now use `false` for
`useActionResolver`. Tests have been updated, with functionality that
depends on `ActionResolver` moving to dispatcher_test.ts.

PR Close #56369

PR Close #56369
2024-06-26 08:49:30 -07:00
Kristiyan Kostadinov
cf059979d7 refactor(core): support let declarations during hydration (#56527)
Updates the hydration logic to account for the fact that let declarations don't create a DOM node.

PR Close #56527
2024-06-26 08:48:32 -07:00
Kristiyan Kostadinov
37b6c937ce refactor(core): integrate let instructions into the runtime (#56527)
Adds the implementation of the following new instructions:
* `declareLet` - creation-time instruction that initializes the slot for a let declaration.
* `storeLet` - update-time instruction that stores the current value of a let declaration.
* `readContextLet` - instruction that reads the stored value of a let declaration from a different view.

On top of the instructions, it also introduces a new `LetDeclaration` TNode type.
The new TNode is nececessary for DI to work correctly in pipes inside the let expression,
as well as for proper hydration support.

PR Close #56527
2024-06-26 08:48:32 -07:00
Matthieu Riegler
5f9bd5521e fix(core): prevent calling devMode only function on @defer error. (#56559)
`getTemplateLocationDetails()` is a devMode only function and should guarded by `ngDevMode` or calling it will throw an error.

fixes #56558

PR Close #56559
2024-06-25 09:17:34 -07:00
Gerald Monaco
be9e4892f9 fix(core): improve support for i18n hydration of projected content (#56192)
When collecting nodes from the DOM for hydration, we need to treat nodes with paths (e.g. content projection) as the new root for all subsequent elements, not just the next one.

Additionally, when using content projection it's possible for translated content to become disconnected, e.g. when it doesn't match a selector and there isn't a default. We need to handle such cases by manipulating the disconnected node data associated with hydration as usual.

PR Close #56192
2024-06-20 14:59:58 -07:00
cexbrayat
2f73281dfd fix(core): improve docs on afterRender hooks (#56525)
This commit improves the documentation of the options parameter of the afterRender hooks.

PR Close #56525
2024-06-20 14:58:51 -07:00
Andrew Kushnir
69e0aa56f1 refactor(core): use performance API for Event Replay (#56509)
This commit adds a standard performance marker that can be viewed in Chrome dev tools and other tooling.
See more info at https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark

PR Close #56509
2024-06-20 08:53:19 -07:00
Andrew Kushnir
83ffa94783 fix(core): do not activate event replay when no events are registered (#56509)
This commit adds extra checks to handle a situation when an application has no events configured, but the Event Replay feature was enabled. This situation can happen when some routes in an application are mostly static, when other routes are more interactive.

Resolves #56423.

PR Close #56509
2024-06-20 08:53:19 -07:00
arturovt
284705f5f4 refactor(core): missing space in zoneless warning (#56491)
There's currently a missing space in the zoneless warning, showing words together.

PR Close #56491
2024-06-20 08:49:40 -07:00
Kristiyan Kostadinov
bc655bf309 refactor(compiler): integrate let declarations into the template pipeline (#56299)
These changes integrate let declarations into the template pipeline. This involves a few operations:
* Producing a `declareLet` instruction call at creation time to initialize the declaration.
* Producing a `storeLet` instruction call in the place of the let declaration, including the necessary `advance` calls beforehand.
* For let declarations used within their declaration view, moving the `const` to be placed right after the `storeLet` call to ensure the their value has been computed.
* For let declarations that are _only_ used in their declaration view, removing the `storeLet` call and inlining the expression into the constant statement.

PR Close #56299
2024-06-20 08:48:53 -07:00
Joey Perrott
cc6cd08ca3 refactor(docs-infra): complete removal of aio directory (#56496)
Finish removal of aio directory as it is no longer used or relied upon.

PR Close #56496
2024-06-18 12:26:04 -07:00
Andrew Kushnir
1d48e72ba7 refactor(core): handle incomplete DOCUMENT instances during cleanup in tests (#56422)
`DOCUMENT` instances retrieved from DI may not contain a necessary function to complete the cleanup. In tests that don't interact with DOM, the `DOCUMENT` might be mocked and some functions might be missing. For such tests, DOM cleanup is not required and we can skip DOM cleanup logic if there are missing functions. For tests that use DOM, TestBed would behave the same as before and rely on more complete `DOCUMENT` instances.

PR Close #56422
2024-06-17 09:05:53 -07:00
Andrew Kushnir
38010d2b3a refactor(core): avoid exposing OutletInjector in injector resolution path (#56394)
Router's `OutletInjector` required a special handling in cases when `@defer` is used, see https://github.com/angular/angular/pull/55374 for additional info. As a result, the `ChainedInjector` that represents an `OutletInjector` instance is currently exposed via `getInjectorResolutionPath` function. This creates a problem, because other debug APIs used by DevTools can not interact with `ChainedInjector`s. This commit updates the logic around `getInjectorResolutionPath` utility to avoid exposing `OutletInjector`in the resolution path.

Resolves #56331.

PR Close #56394
2024-06-17 09:05:12 -07:00
Paul Gschwendtner
5c2f308858 refactor(core): ModelSignal should extend InputSignal (#56452)
This allows for helpers like the following to work intuitively for all
types of "input fields". It also establishes the intended mental
philosophy that a model is both an input and an output.

```ts
/** Unwraps all signal input properties. */
export type UnwrapSignalInputs<T> = {
  [K in keyof T]: T[K] extends InputSignalWithTransform<any, infer WriteT>
    ? WriteT
    : T[K];
};
```

PR Close #56452
2024-06-17 08:59:59 -07:00
Matthieu Riegler
0dbca3726c docs(core): remove the doc link for NG0952 (#56441)
We don't have any docs yet for that error, so I'm removing the minus sign which indicate that there is a dedicated error doc.

Fixes #56424

PR Close #56441
2024-06-14 10:05:01 -07:00
Andrew Kushnir
a620231c03 Revert "refactor(core): Use ActionResolver in Dispatcher. (#56369)" (#56440)
This reverts commit 4ebd2853fa.

PR Close #56440
2024-06-13 12:17:35 -07:00
Tom Wilkinson
247dce0023 refactor(core): Use ActionResolver in Dispatcher. (#56369)
`EventContract` usages in Angular now use `false` for
`useActionResolver`. Tests have been updated, with functionality that
depends on `ActionResolver` moving to dispatcher_test.ts.

PR Close #56369
2024-06-13 08:50:46 -07:00
Andrew Kushnir
8b8fd167a2 refactor(core): inject PendingTasks as optional in EventEmitter class (#56411)
This commit makes `PendingTasks` dependency in the `EventEmitter` class optional to make sure this code works with various test setups.

PR Close #56411
2024-06-12 13:10:40 -07:00
Andrew Scott
dbd0fa00f8 fix(core): async EventEmitter should contribute to app stability (#56308)
async `EventEmitter` should contribute to app stability.

fixes #56290

PR Close #56308
2024-06-11 15:10:21 -07:00
Andrew Scott
625ca3e2b3 fix(core): signals should be tracked when embeddedViewRef.detectChanges is called (#55719)
This commit fixes an issue where signals in embedded views are not
tracked if they are refreshed with `EmbeddedViewRef.detectChanges`
directly. We had previously assumed that embedded views were always
refreshed along with their hosts.

PR Close #55719
2024-06-11 12:35:03 -07:00
Kristiyan Kostadinov
c07e1b3356 fix(migrations): resolve error in standalone migration (#56302)
This is related to an issue that was reported internally. We were assuming that `hasNgModuleMetadataElements` will return true only for property assignments initialized to arrays, but that's not the case.

These changes update the type and our assertions to more accurately reflect the AST and to avoid the error.

PR Close #56302
2024-06-07 09:33:42 -07:00
Thomas Nguyen
dbf1d9361e refactor(core): Refactor parts of event_replay into a shared library that will be used with global event delegation. (#56172)
This also moves the code that stashes the jsaction more closely to the code that actually sets the event listener.

PR Close #56172
2024-06-05 16:35:23 +00:00
Tom Wilkinson
33a6686806 refactor(core): Add and move tests for Dispatcher. (#56193)
Move tests from `eventcontract_test.ts` to `dispatcher_test.ts` for
functionality that lives in `Dispatcher`.

Add an extra test for `preventDefault` behavior for `CLICKMOD` that
covers a previous bug case.

PR Close #56193
2024-06-04 18:05:39 +00:00
Matthieu Riegler
33b0d25bfd refactor(core): Use Nullish coalescing assignment for view getters. (#56242)
Micro optim, this wasn't minified by the optimizer.

PR Close #56242
2024-06-03 20:10:35 +00:00
Alan Agius
a33d85dcb7 build: update Node.js to match Angular CLI engines (#56187)
The current supported Node.js engines by the Angular CLI are `^18.19.1 || ^20.11.1 || >=22.0.0`

PR Close #56187
2024-06-03 18:00:46 +00:00
Paweł
c3f2c67fa0 refactor(core): remove doubled line (#56091)
remove doubled line of titlecase pipe in commonModulePipes array

PR Close #56091
2024-05-31 13:24:55 +00:00
Andrew Scott
159c97ec69 refactor(core): provide zone token in prod as well (#56197)
This allows us to make decisions based on whether zone is provided for
when zoneless is the default.

PR Close #56197
2024-05-30 19:24:30 -07:00
Andrew Kushnir
290a47d842 fix(core): handle missing withI18nSupport() call for components that use i18n blocks (#56175)
This commit updates hydration serialization logic to handle a case when the `withI18nSupport()` call is not present for an application that has a component that uses i18n blocks. Note: the issue is only reproducible for components that also inject `ViewContainerRef`, since it triggers a special serialization code path.

Resolves #56074.

PR Close #56175
2024-05-30 18:36:58 +00:00
Tom Wilkinson
2a440e1064 fix(core): Fix shouldPreventDefaultBeforeDispatching bug (#56188)
When I copied this over in caedd10597
the parentheses moved around the A tag check and the CLICK type check,
instead of around the CLICK and CLICKMOD check.

PR Close #56188
2024-05-30 17:54:55 +00:00
Alex Rickabaugh
616cdef474 fix(core): don't coerce all producers to consumers on liveness change (#56140)
When a consumer switches its liveness state, it gets added to / removed from
the consumer list of all of its producers. This operation is transitive, so
if its producer is *also* a consumer and *its* liveness state is switched,
then the change is applied recursively.

Note that this only matters *if* the producer is also a consumer. However,
the logic in `producerAddLiveConsumer` / `producerRemoveLiveConsumerAtIndex`
coerced the producer node into a producer & consumer node, which allocated
extra arrays into the node structure that are never used. This didn't affect
correctness, but increased the memory usage of plain signal nodes (which are
just producers, never consumers).

This fix changes the logic in those operations to simply check if a producer
is also a consumer instead of coercing it into one.

PR Close #56140
2024-05-30 17:44:56 +00:00
Thomas Nguyen
7659dffa3f refactor(core): Remove lambda from error message. (#56161)
This should've been in the previous PR, but a bad rebase removed it.

PR Close #56161
2024-05-30 17:30:53 +00:00
Thomas Nguyen
0e3e6d4336 refactor(core): Switch a .includes to a .indexOf(), as this is currently (#56046)
breaking internal tests that assert no usage of Array ES6 methods.

PR Close #56046
2024-05-30 15:30:52 +00:00
Andrew Kushnir
0c39a46a88 refactor(core): replace AIO link with ADEV one in hydration message (#56178)
This commit updates the content of hydration-related message and replaces AIO with ADEV domain.

PR Close #56178
2024-05-30 14:57:11 +00:00
Kristiyan Kostadinov
989a8e126e refactor(compiler): implement let declarations in render3 ast (#55848)
Introduces a new `LetDeclaration` into the Render3 AST, simiarly to the HTML AST, and adds an initial integration into the various visitors.

PR Close #55848
2024-05-30 14:55:37 +00:00
Matthieu Riegler
78cf9bfc0e fix(core): Do not migrate HttpClientModule imports on components. (#56067)
`provideHttpClient()` returns a `EnvironmentProvider` which is not compatible with component providers.

PR Close #56067
2024-05-30 14:55:06 +00:00
Kristiyan Kostadinov
b70b80ba55 fix(migrations): do not generate aliased variables with the same name (#56154)
Adds some logic to avoid generating expressions like `let $index = $index` in the control flow migration.

Fixes #56152.

PR Close #56154
2024-05-30 14:54:36 +00:00
Andrew Scott
50f8191fbf refactor(core): privately export token that indicates if zone CD is provided (#56137)
This will allow us to internally decide how to configure things when the default is zoneless.

PR Close #56137
2024-05-30 13:48:08 +00:00
naaajii
ba85d08158 fix(migrations): handle empty ngSwitchCase (#56105)
empty ngSwitchCase generate `case ()` which isn't valid syntax therefore adding quotes will help prevent us migrate empty case if no condition was provided

fix angular#56030

PR Close #56105
2024-05-29 15:38:39 +02:00
Thomas Nguyen
4fdc93bcd5 refactor(core): Use event_dispatcher in event_replay code. (#56036)
This makes events bubble! This change also contains changes to
dispatcher and event_dispatcher to make replay synchronous,
so that we avoid odd timing issues. This can be split out though.

Lastly, we have one cleanup change to move the mapping from
event type to functions on the element itself.

PR Close #56036
2024-05-29 12:59:23 +02:00
Alan Agius
fa4bcf3621 test: add back control_flow_migration tests (#56130)
These were incorrectly removed via https://github.com/angular/angular/pull/55391#issuecomment-2135352758

PR Close #56130
2024-05-28 16:48:08 +02:00
Kristiyan Kostadinov
0b6018b755 build: update to latest dev infra code (#56128)
Updates the repo to the latest dev infra code which involves updating a patch and renaming all the golden files to end with `.api.md`.

PR Close #56128
2024-05-28 14:42:31 +02:00
Andrew Kushnir
4e6ea0e19c fix(core): handle elements with local refs in event replay serialization logic (#56076)
Previously, the event replay serialization logic was located before we verify that a `TNode` exists. `TNode`s may not exist in `tView.data` array in several cases, including cases when there is a local ref used on an element: in this case an extra slot in `LView` contains a reference to the same element and `TNode` is not needed. This commit moves the event replay serialization logic a bit lower, after we check for TNode presence.

Resolves #56073.

PR Close #56076
2024-05-27 13:50:10 +02:00
Andrew Scott
47b7ba0d5e refactor(core): Remove hybrid mode flag and move scheduler provider location (#55722)
The flag is not used anymore and, as a result, is easier to move the
scheduler provider.

PR Close #55722
2024-05-23 18:15:53 +02:00
Thomas Nguyen
89e48aac4e refactor(core): Create event types that are able to be serialized, captured, or are mouse events. (#55799)
Use these constants across jsaction and Angular.

PR Close #55799
2024-05-23 16:10:47 +02:00
Thomas Nguyen
01a19f33b5 refactor(core): Make sure not to do anymore jsaction work once everything is replayed. (#55799)
Without this, I think subsequent renders will populate data structures.

PR Close #55799
2024-05-23 16:10:47 +02:00
Matthieu Riegler
d73a0175cb fix(core): link errors to ADEV (#55554)
Console error links will now point to adev.

PR Close #55554
2024-05-23 11:58:54 +02:00
Matthieu Riegler
b960aad863 refactor(core): remove unused preventDefault on listener (#55879)
`wrapListener` was only invoked with `wrapWithPreventDefault` set to `false`.

PR Close #55879
2024-05-22 16:08:40 -07:00
Tom Wilkinson
9f63df9d1b refactor(core): Add a new EventDispatcher class. (#55837)
`EventDispatcher` emulates the browser's event dispatch (mostly).
It supports:
 - Bubbling and `stopPropagation`/`stopImmediatePropagation`.
 - `currentTarget` during dispatch.
 - Throwing errors for `preventDefault` if the event is being dispatched
   in replay.
 - Throwing errors for `composedPath()` if event is being dispatched in
   replay.

PR Close #55837
2024-05-22 15:24:01 -07:00
cexbrayat
985a215b10 fix(core): typo in zoneless warning (#55974)
The warning introduced in ae0baa25 mispelled `applications`.

PR Close #55974
2024-05-22 15:22:19 -07:00