Commit graph

14463 commits

Author SHA1 Message Date
SkyZeroZx
7d1e502345 feat(forms): Allows transforms on FormUiControl signals
Extends the `FormUiControl` interface to allow `InputSignalWithTransform` in addition to `InputSignal` for its properties.

Fixes #65756
2025-12-03 15:13:01 +01: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
Alan Agius
0659d11c85
fix(http): enable XSRF protection for same-origin absolute URLs
Previously, the XSRF interceptor only added the XSRF token to requests with relative URLs.
This commit updates the interceptor to also add the token to requests with absolute URLs, provided they match the current origin.
2025-12-03 12:19:43 +01:00
Kristiyan Kostadinov
6773d3b97d fix(compiler-cli): check that field radio button values are strings
Adds some type checking code which verifies that the bound `value` on a `Field` radio button is a string.

Fixes #65726.
2025-12-03 12:18:57 +01:00
arturovt
b74a0693f2 fix(router): handle errors from view transition finished promise
This commit adds a `.catch()` handler to `transition.finished` from `document.startViewTransition` to prevent unhandled promise rejections. The finished promise can reject with `TimeoutError` or `InvalidStateError` when transitions fail during or after the animation phase.

Based on the Blink source code, the `finished` promise can reject with:
* `TimeoutError`: "Transition was aborted because of timeout in DOM update"
* `InvalidStateError`: "Transition was aborted because of invalid state"

This may happen when the DOM update phase exceeds the browser's internal timeout threshold.
2025-12-03 12:16:57 +01:00
Andrew Scott
a0ad5d4b2b test(router): Add tests for support of path params before/after a wildcard
This adds additional tests following the initial implementation in #64737 that cover
the use-case of path parameters before and after the wildcard segment.
2025-12-02 16:46:17 +01:00
Andrew Scott
fd65dc5d53 refactor(router): add comment about scroll/focus
Add consideration for future behavior in the completion of the navigation event.
2025-12-02 16:45:17 +01:00
Andrew Scott
cc03254b12 refactor(router): Avoid aborting traversal navigations
Unnecessarily aborting traversal navigations will break focus and scroll
restoration. We need to keep them open rather than replacing them with
an identical router-initiated navigation.
2025-12-02 16:45:17 +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
Kristiyan Kostadinov
e30e61b789 fix(compiler-cli): avoid allocating an object for signals in production mode
Currently when the signal debug name transform sees something like `const foo = signal(0);`, it transforms the signal into `signal(0, {...(ngDevMode ? { debugName: 'foo' } : {})})`. After minification this becomes `signal(0, {})` which will allocate memory for the empty object literal.

These changes rework the logic to produce `signal(0, ...(ngDevMode ? [{ debugName: 'foo' }] : []))` which will be fully tree shaken away to `signal(0)`.
2025-12-02 15:06:51 +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
Matthieu Riegler
f35b2ef47c refactor(compiler): Generate the controlCreate instruction after the native element has been created
This is necessary to exclude a race condition where the MutationObserver initialized by the instruction fired before the inputs are binded.

fixes #65678
2025-12-02 12:59:49 +01:00
Matthieu Riegler
a784995a98 docs(docs-infra): Show examples on function overloads 2025-12-02 12:13:11 +01:00
Angular Robot
19a36954c1 build: update dependency chokidar to v5
See associated pull request for more information.
2025-12-02 12:11:10 +01:00
Tim Deschryver
680de24c3c docs: fix documentation link for currentNavigation method 2025-12-02 12:02:24 +01:00
SkyZeroZx
2d854e01bc docs(docs-infra): Improves symbol linking for Angular Aria selectors
Improves the symbol linking logic to handle Angular component selectors (e.g., ngCombobox). It attempts to convert Angular selector patterns to their corresponding class names, improving navigation to Angular API documentation.
2025-12-01 18:47:19 +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
Matthieu Riegler
c1dfd9cde6 refactor(migrations): don't migration the server bootstrapApplicaiton on zoneless apps.
With the change we specifically analyse `boostrapApplication` with a config that uses `mergeApplicationConfig`.

fixes #65408
2025-11-26 15:58:53 -05: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
Matthieu Riegler
5b720aa2eb refactor(core): show error message on signal error
When a signal throws an error on read. The formatter will show the error message.
2025-11-26 13:11:07 -05:00
Angular Robot
e681c871d3 build: update all non-major dependencies
See associated pull request for more information.
2025-11-26 13:08:42 -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
40790ef980 fix(http): prevent XSRF token leakage to protocol-relative URLs
The XSRF interceptor previously failed to detect protocol-relative URLs (starting with `//`) as absolute URLs. This allowed requests to such URLs to include the XSRF token, potentially leaking it to external domains.

This change updates the interceptor to correctly identify protocol-relative URLs as absolute and exclude them from receiving the XSRF token.
2025-11-25 13:47:26 -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
Kristiyan Kostadinov
c994267f17 refactor: add mark for signal forms
Adds a mark for signal forms so we can track adoption. Also moves the call for `@let` into `declareLet` since we don't need it to fire as often as in `storeLet`.
2025-11-25 13:03:43 -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
AntonChesnokov
5bfa027d41 fix(compiler-cli): escape angular control flow in jsdoc
Escape @-prefixed template control flow constructs during doc extraction so JSDoc parsing keeps description text intact. Add regression coverage for @for snippets.
2025-11-25 11:33:25 -05:00
kirjs
dec222d4d7 refactor(forms): Make reset take value
Now you can do form.reset({name: 'cat', age: 4});
2025-11-25 10:51:35 -05:00
Miles Malerba
c70e246c23
feat(forms): add DI option for classes on Field directive
Adds a DI configuration option for signal forms that allows the
developer to specify CSS classes that should be automatically added
by the `Field` directive based on the field's status.
2025-11-25 10:33:38 -05:00
SkyZeroZx
67d41e9bcc docs: improve core package API documentation with additional reference links 2025-11-25 10:19:36 -05:00
Leon Senft
3a1eb07c46 fix(forms): allow dynamic type bindings on signal form controls
The type checker will no longer prohibit binding the Signal Forms `[field]`
directive to an input with a dynamic `[attr.type]` or `[type]` binding.
2025-11-25 09:15:58 -05:00
Andrew Scott
51ebe9a4fc refactor(core): Remove toggles used for zoneless by default migration
this migration is complete both internally and externally
2025-11-24 16:57:49 -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
Matthieu Riegler
b34e48bdff docs: add callout on zone base testing helpers
With zoneless being the default, we need to make these requirements more explicit.

fixes #65539
2025-11-24 13:27:46 -05:00
SkyZeroZx
2ac826867b docs: Update router docs to add references and components input fixed syntaxis 2025-11-24 13:18:28 -05:00
Alessio Pelliccione
7d20f2071c docs(docs-infra): fix missing syntax highlighting
closed angular#65565
2025-11-24 13:13:22 -05:00
Kristiyan Kostadinov
6b8720de91 fix(compiler-cli): do not type check native controls with ControlValueAccessor
Currently when we detect a `field` binding on a native element, we treat it as a built-in native control. This might not be the case if it's a pre-existing `ControlValueAccessor` relying on the CVA interop.

These changes try to detect any CVA-like directive on the element and disable the additional type checking if there are any.

Fixes #65468.
2025-11-24 13:08:42 -05:00
Kristiyan Kostadinov
5cfdd7897b refactor(compiler-cli): track public methods during analysis
Updates the directive analysis to track the public methods of the class.
2025-11-24 13:08:42 -05:00
Tomer953
a4f50bdd54 fix(migrations): detect structural ngTemplateOutlet and ngComponentOutlet
the common-to-standalone migration only matched [ngTemplateOutlet] and
[ngComponentOutlet] bindings and missed their structural forms
(*ngTemplateOutlet and *ngComponentOutlet). This caused missing imports
when removing CommonModule. This change adds structural directive
patterns so the migration correctly identifies needed imports.
2025-11-24 12:40:57 -05:00
hawkgs
0f4b11c293 refactor(compiler-cli): add a resource debugName transform (#64172)
Add a TS transform for `resource` (and `httpResource`) `debugName`. Test the transformations.

PR Close #64172
2025-11-24 11:30:12 -05:00
hawkgs
3ae452e64f refactor(core): add debug name to resource (#64172)
Decorate `resource` (and `httpResource`) with `debugName`, along with all of its internal signals.

PR Close #64172
2025-11-24 11:30:12 -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
SkyZeroZx
38a354ffa2 docs: Adds signal type checking documentation 2025-11-21 16:31:13 -05:00
Matthieu Riegler
b6fee3f107 fix(core): apply bootstrap-options migration to platformBrowserDynamic
The migration wasn't applied to projects relying on `platformBrowserDynamic()` prior to this fix.
2025-11-21 16:28:20 -05:00
Syam Gadde
1628125bcb fix(compiler-cli): ignore non-existent files
Ignore files that fail fs.exists() rather than throw ENOENT.  Some applications deliberately create "broken" symbolic links that are not relevant to compilation (e.g. emacs lock files that link to owner "user@host").
2025-11-21 11:38:57 -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