Commit graph

3388 commits

Author SHA1 Message Date
Kristiyan Kostadinov
a0dfa5fa86 feat(core): support rest arguments in function calls
Updates the template syntax to support rest arguments in function calls. This can be handy for functions with a variable number of arguments.
2026-01-07 12:37:52 -05:00
Kristiyan Kostadinov
6e18fa8bc9 feat(core): support spread elements in array literals
Expands the template syntax to support spread elements inside arrays. This can be handy for some bindings.
2026-01-07 12:37:52 -05:00
Kristiyan Kostadinov
e407280ab5 feat(core): support spread expressions in object literals
Adds support for spread expressions inside of object literals. This can be handy when constructing maps for `class` bindings.
2026-01-07 12:37:52 -05:00
Andrew Scott
97fd1de0ac Revert "refactor(router): Add support for precommitHandler in Navigation integration"
This reverts commit 522fa716b8.
2026-01-07 11:45:58 -05:00
Matthieu Riegler
640693da8e feat(compiler): Add support for multiple swich cases matching
consecutive `@case` blocks are now supported:

```ts
@switch (case) {
  @case (0)
  @case (1) {
    case 0 or 1
  }
  @case (2) {
    case 2
  }
  @default {
    default
  }
}
```

fixes #14659
2026-01-07 09:23:50 -05:00
Andrew Scott
e44839b016 feat(router): Add standalone function to create a comptued for isActive
This change deprecates `Router.isActive` in favor of a function that
creates a computed which tracks whether a given url/UrlTree is active,
following changes in the router state.

`Router.isActive` contributes ~1333b to the bundle size, but is only
used by developers who use the API directly or who use
`RouterLinkActive`. It should not contribute to bundle sizes of
applications that do not use this functionality.
2026-01-07 09:23:06 -05:00
Andrew Scott
522fa716b8 refactor(router): Add support for precommitHandler in Navigation integration
The `precommitHandler` of the Navigation API unlocks some of the truly
powerful features for Routers like Angular's which defer the URL
updates. Without the `precommitHandler`, we cannot initiate a navigation
until we are ready to commit the URL because it causes the URL to update
immediately.

With `precommitHandler` support, we are able to create a `NavigateEvent`
_immediately_ on navigation, which allows the browser to show that a
navigation is happening with a loading indicator. Site visitors will
also have the ability to cancel the navigation with the "stop" button.
When we are ready to commit the URL, the precommitHandler supports a
"redirect" function that we can use to first redirect the navigation to
a new location immediately before committing it.

The commit operation is not synchronous because the API waits for all
precommitHandlers to resolve. This commit adds a small bit of handling
to account for this so that the Router's transition does not advance
to the next stage until the URL has been committed.
2026-01-06 16:10:56 -05:00
Alan Agius
91dc91bae4
fix(core): sanitize sensitive attributes on SVG script elements
This commit updates the DOM security schema and sanitization logic to properly recognize and sanitize `href` and `xlink:href` attributes on SVG `<script>` elements.
2026-01-06 15:49:52 -05:00
Andrew Scott
db470f0881 refactor(router): Remove internal rxjs recognize implementation
All uses of this have been removed internally and it's no longer needed
2026-01-06 10:13:19 -05:00
SkyZeroZx
1532be9d00 refactor(core): introduce tree-shakeable runtime error codes for NgModule handling and ViewContainerRef errors
Adds new tree-shakeable runtime error codes to improve error reporting for
NgModule resolution issues (duplicate or missing IDs) and invalid ViewContainerRef
operations involving destroyed views.
2026-01-05 16:52:24 -05:00
Andrew Scott
5edceffd04
feat(router): add controls for route cleanup
This commit introduces a new feature to automatically destroy `EnvironmentInjector`s associated with routes that are no longer active or stored. This helps in managing memory by releasing resources held by unused injectors.
2026-01-05 14:43:56 -05:00
Angular Robot
29574f622d build: update cross-repo angular dependencies
See associated pull request for more information.
2026-01-02 14:24:17 +01:00
Kristiyan Kostadinov
1765ebe79b Revert "refactor(core): Add ngDevMode guards and new sanitization error codes"
This reverts commit 4e7e38c591.
2026-01-02 11:37:24 +01:00
SkyZeroZx
4e7e38c591 refactor(core): Add ngDevMode guards and new sanitization error codes
Adds new runtime sanitization error codes. Adds `ngDevMode` guards around
error message strings to ensure detailed diagnostics are included only
in development mode. This allows production builds to tree-shake verbose error descriptions, reducing bundle size.
2026-01-02 08:08:21 +01:00
Andrew Scott
99ad18a4ee feat(core): Add stability debugging utility
This commit adds a utility method to debug why the application has not stabilized after
a set period of time (9 seconds, or `hydrationTimeout-1`).

fixes #52912
2025-12-17 15:43:05 -08:00
Matthieu Riegler
6270bba056 ci: reformat files
This is after we've slightly changed a rule in #66056
2025-12-16 14:44:19 -08:00
Andrew Scott
06be8034bb fix(core): Microtask scheduling should be used after any application synchronization
Previously, Angular would switch from the macrotask to a microtask
scheduler _only_ when the scheduler was the trigger for the
synchronization. This microtask scheduling is to ensure patterns such as
`Promise.resolve().then(() => updateAppStateAgain())` _during_
synchronization are caught and synchronized again within the same event
loop (guaranteeing that they aren't split across multiple browser paints).

The microtask scheduler should be used after any tick, not just from
those than run within the scheduler to always account for the promises
within synchronization. This is encountered most frequently during
bootstrap, which triggers the tick directly.

In this change we exempt `TestBed.tick` and
`ComponentFixture.detectChanges` from this behavior. Doing so would affect
the timing of stability and tests are quite sensitive to this (e.g.
`fixture.whenStable`). It is somewhat unfortunate that we have "special" test-only
behavior. However, it is important to acknowledge that this only affects
the test-only APIs as well. Any code in the application under test that
triggers `ApplicationRef.tick` directly would still use the microtask
scheduling behavior.

fixes #65444
2025-12-16 13:34:48 -08:00
Alan Agius
d4111eebc6
refactor(compiler): remove unnecessary sanitization for safe attributes
Remove sanitization for attributes that cannot execute code (e.g. `javascript: URIs`).
2025-12-15 14:13:38 -08:00
Andrew Kushnir
8243bb3064 Revert "refactor(compiler): remove unnecessary sanitization for safe attributes"
This reverts commit 128aef0ede.
2025-12-12 12:59:47 -08:00
Kristiyan Kostadinov
7be4ddef1c fix(core): throw better errors for potential circular references
Currently circular references in user code manifest themselves with an error like `Cannot read properties of undefined (reading 'ɵcmp')`. This is a bit cryptic so these changes add an assertion mentioning circular references.

Relates to #65917.
2025-12-12 08:06:26 -08:00
Alan Agius
128aef0ede
refactor(compiler): remove unnecessary sanitization for safe attributes
Remove sanitization for attributes that cannot execute code (e.g. `javascript: URIs`).
2025-12-12 08:05:58 -08:00
Angular Robot
d0c3806915 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-12-10 13:20:56 -08:00
Kristiyan Kostadinov
ae1c0dc490 perf(compiler): chain query creation instructions
We always emit the query creation instructions in a group which makes them good candidates for chaining.
2025-12-09 09:24:36 -08:00
Matthieu Riegler
9d1d742f1b build: enable angular formatting on all html files
This should also be safe on any html file that isn't an angular template
2025-12-08 10:19:45 -08:00
Joey Perrott
aba8fbe5cd
build: update cross-repo angular dependencies
See associated pull request for more information.
2025-12-08 08:40:42 -08:00
Leon Senft
e6d5632a30 perf(core): tree shake unused dynamic [field] binding instructions (#65599)
Move the instructions used to dynamically bind a `Field` directive to a
form control onto the `Field` itself. This way the instructions are only
retained if the app uses the `Field` directive.

PR Close #65599
2025-12-03 15:10:49 +01:00
Leon Senft
cd7ae7e2ce fix(forms): support dynamic [field] bindings (#65599)
Support binding a `Field` directive to a component created dynamically
with `createComponent()`.

Fix #64632

PR Close #65599
2025-12-03 15:10:49 +01:00
Kristiyan Kostadinov
886cf6c452 fix(core): unable to inject viewProviders when host directive with providers is present
When registering providers, the DI system assumes that `viewProviders` are registered before plain `providers`. This was reinforced by components always being first in the array of directive matches, only one component being allowed per node and the fact that only components can have `viewProviders`.

This breaks down if there are host directives with `providers` on the component, because they'll execute earlier, throwing off the order of operations.

These changes fix the issue by separating out the resolvers for `viewProviders` and plain `providers` and explicitly running the component's `viewProviders` resolver before any others. This also has the benefit of not attempting to resolve `viewProviders` for directives which are guaranteed not to have them.

Fixes #65724.
2025-12-03 15:09:48 +01:00
Andrew Scott
9914926b0d refactor(router): Clean up cancellation event handling
cleans up some handling of cancellation events with a shared helper.
2025-12-02 16:45:17 +01:00
Andrew Scott
b7d21e209a refactor(router): compress synchronous end to router navigation to single operator
The end of the Router navigation is a block of synchronous logic that
can be compressed into a single operator rather than splitting it across
several, making it harder to step through. The only benefit from the
split is automatic unsubscribe/cancellation, which we can replicate
with an additional 'shouldContinue' check before proceeding.
2025-12-02 16:44:01 +01:00
Jessica Janiuk
d8ab83ca82 fix(core): run animation queue in environment injector context
In the case that a component injector is destroyed before the animation
queue runs, the animation queue would fail to run because it was using a
destroyed injector. This commit changes the animation queue to run in the
context of the EnvironmentInjector, which is not destroyed until the app
is destroyed.

fixes: #65628
2025-12-02 15:05:17 +01:00
Alan Agius
1c6b0704fb
fix(compiler): prevent XSS via SVG animation attributeName and MathML/SVG URLs
This commit implements a security fix to prevent XSS vulnerabilities where SVG animation elements (`<animate>`, `<set>`, etc.) could be used to modify the `href` or `xlink:href` attributes of other elements to `javascript:` URLs.
2025-12-01 10:26:56 +01:00
Angular Robot
42e73ff9ce build: update cross-repo angular dependencies
See associated pull request for more information.
2025-11-26 15:50:56 -05:00
Leon Senft
add8c41e5b
test(core): test bundling of dynamic component creation and bindings
Add test coverage for bundling dynamic component creation API like
`createComponent()` and `inputBinding()`. This will be used to test that
Signal Forms related features for #64632 can be tree-shaken when unused.
2025-11-26 11:57:15 -05:00
Alan Agius
400fc82c43 refactor: replace getDocument() with inject(DOCUMENT)
This replaces `getDocument()` with `inject(DOCUMENT)` across hydration and transfer state logic.
2025-11-25 13:04:58 -05:00
Alan Agius
3b1fa8235b fix(core): use injected DOCUMENT for CSP_NONCE
This ensures that the right document is used and that `CSP_NONCE` can be used in `provideAppInitializer` and `provideEnvironmentInitializer`.

Closes #65624
2025-11-25 11:39:20 -05:00
Kristiyan Kostadinov
ca6ab6c914 fix(core): debug data causing memory leak for root effects
We track all effects that are created for debugging purposes in the `resolverToEffects` map. This ends up leaking memory for effects registered on long-living resolvers (e.g. on the root injector), because they stay in the array, even if the effect itself has been destroyed.

These changes add a callback to clean up the references.

Fixes #65265.
2025-11-24 15:26:09 -05:00
Leon Senft
f97a1d4856 refactor(forms): support custom control directives
Support binding `[field]` to directives that implement
`FormValueControl` or `FormCheckboxControl`.

The `[field]` binds to whichever directive (or component) matches first in the
event there are multiple implementations. We are considering whether to make
this an error state, which could be reported during type checking.

Closes #63910, Closes #64992
2025-11-24 13:48:17 -05:00
Kristiyan Kostadinov
26e2092dd1 test: remove unnecessary test calls
Removes calls to `TestBed.configureTestingModule` since they aren't necessary.
2025-11-24 10:18:18 -05:00
Andrew Scott
1ab461c846 refactor(router): Store route injector on ActivatedRoute instance
This eliminates the need to pass around the EnvironmentInjector
everywhere we need the injection context for a route.
2025-11-20 17:05:10 -05:00
JoostK
913cde8ab4 refactor(core): let the profiler handle asymmetric events leniently
Although the prior commit has made more profiler events guaranteed symmetric
through the use of finally-blocks, there continue to be some situations
that could potentially result in asymmetric events, e.g. application
bootstrap doesn't guarantee symmetric events. This commit makes the profiler
lenient to these situations by unrolling the stack past the asymmetric event
data, eventually reaching the expected start event.
2025-11-20 12:29:59 -05:00
JoostK
3760045e3e fix(core): notify profiler events in case of errors
Profiler events are expected to be symmetric, yet in the case of errors this symmetry may break
if events aren't always kept in sync with their corresponding start event. This commit moves
various end events to be run from a finally-block, allowing them to notify the profiler even
when an error has occurred.

Fixes #62947
2025-11-20 12:29:59 -05:00
tsc036
34e1fe235f
refactor(core): export profile event as enum and move profile_types.ts and framework to shared devtools folder
move framework enum and profile_types to a shared folder so it can be used by wiz
2025-11-19 15:22:49 -08:00
Angular Robot
4c31f8ebf4 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-11-19 15:00:49 -08:00
Kristiyan Kostadinov
5e6d8573f4 perf(core): avoid repeat searches for field directive
The `getControlDirective` is called multiple times, both at init and during each update run. Under the hood it performs a linear search for the `Field` directive.

We can speed this up by finding its index once and reusing it since the array of directive matches is static.
2025-11-19 14:28:56 -08:00
Angular Robot
7e9f1cc8d8 build: update cross-repo angular dependencies
See associated pull request for more information.
2025-11-18 15:28:38 -08:00
Angular Robot
6178e3ebfb build: update cross-repo angular dependencies
See associated pull request for more information.
2025-11-17 16:34:41 -08:00
Jessica Janiuk
88dfd96ec9 Revert "refactor(core): let the profiler handle asymmetric events leniently"
This reverts commit da9911f2b4.
2025-11-17 10:10:36 -08:00
Jessica Janiuk
adc2a57be0 Revert "fix(core): notify profiler events in case of errors"
This reverts commit af1ba52587.
2025-11-17 10:10:36 -08:00
JoostK
da9911f2b4 refactor(core): let the profiler handle asymmetric events leniently
Although the prior commit has made more profiler events guaranteed symmetric
through the use of finally-blocks, there continue to be some situations
that could potentially result in asymmetric events, e.g. application
bootstrap doesn't guarantee symmetric events. This commit makes the profiler
lenient to these situations by unrolling the stack past the asymmetric event
data, eventually reaching the expected start event.
2025-11-17 09:40:04 -08:00