Commit graph

27 commits

Author SHA1 Message Date
Ben Hong
390efd51e7 docs: add new debugging and troubleshooting di guide
(cherry picked from commit 13e019a1bb)
2026-02-20 18:01:16 +00:00
Alex Rickabaugh
a67e00741c refactor(forms): move control logic into FormField directive
Refactors the `ɵɵcontrolCreate` and `ɵɵcontrol` instructions to delegate control logic to the forms package via new `ɵngControlCreate` and `ɵngControlUpdate` lifecycle hooks. Previously, the logic for binding form state to native elements and custom controls was hardcoded within `@angular/core`.

**Compiler Changes:**
- Introduces a new compilation phase `specializeControlProperties` (in `control_directives.ts`).
- This phase detects properties named `formField` and specializes them into `ControlCreate` and `Control` IR opcodes.
- These opcodes emit `ɵɵcontrolCreate` and `ɵɵcontrol` instructions, respectively.

**Runtime Changes:**
- `ɵɵcontrolCreate` acts as the creation phase. It locates the control directive and invokes its `ɵngControlCreate` method.
- `ɵɵcontrol` acts as the update phase, and invokes the control directive's `ɵngControlUpdate` method (if present).
- Introduces a `passThroughInput` configuration in `ControlFeature`. This specifies the input name (e.g., `formField`) that triggers the control. If the runtime detects that this input is bound to multiple targets (e.g., the `FormField` directive *and* the host component), the control is flagged as "pass-through". In this state, `ɵngControlCreate` returns a no-op update function, deferring responsibility to the other consumer (e.g., the component managing the field itself).

**Forms Changes:**
- `FormField` directive implements `ɵngControlCreate` and `ɵngControlUpdate`.
- Inside this hook, `FormField` determines the type of control it is attached to (Native, CVA, or Custom Signal Control) and delegates to the appropriate handler (`nativeControlCreate`, `cvaControlCreate`, or `customControlCreate`).
- Consolidates all form binding logic within `@angular/forms/signals`, enabling support for new `FormValueControl` and `FormCheckboxControl` interfaces.
- Reorganizes the codebase by moving `FormField` from `api/` to `directive/` and splitting the binding logic into semantic pieces:
    - `control_native.ts`, `control_cva.ts`, and `control_custom.ts` contain the specific handlers for each control type.
    - `native.ts` and `select.ts` provide helpers for native element discovery and select-specific synchronization.
    - `bindings.ts` manages the tracking and application of property/attribute bindings.
2026-01-29 13:17:40 -08: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
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
SkyZeroZx
bb65520991 docs: Adds documentation for the NG0919 error
Adds a new documentation page for the NG0919 error, which indicates a circular dependency in Angular applications.

fixes  #65968
2025-12-15 09:52:16 -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
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
Leon Senft
32f86d35f7 perf(forms): optimize [field] binding instructions (#64351)
Caches information about the kind of form control that a `TNode`
represents in `TNodeFlags`. This avoids redundant computations on
subsequent template create and update passes.

Renames the `INVALID_CONTROL_HOST` error code to
`INVALID_FIELD_DIRECTIVE_HOST` for clarity and adds a test for it.

PR Close #64351
2025-10-13 13:02:17 -07:00
Leon Senft
effccffde0 refactor(core): add framework support for binding form controls (#63773)
Move most of the implementation of the `Control` directive into core
framework instructions. This allows field state changes to be propagated
to their corresponding UI controls directly during execution of a
template update block, instead of relying on `effect()`s to synchronize
each change later during the update (and too late in the case of
required inputs).

* Define a private API in `@angular/core` for signal forms to implement:
  * `ɵControl` for the `Control` directive.
  * `ɵFieldState` for the control's associated `FieldState`.
* Emit specialized instructions when compiling a `[control]` binding:
  * `ɵɵcontrolCreate` sets up the `ɵControl` directive if present,
    determines whether it's bound to a native control element or a
    custom control component, and adds the appropriate event listeners
    to notify the `ɵFieldState` of UI changes.
  * `ɵɵcontrol` propagates changes from `ɵFieldState` properties to their
    corresponding UI control properties (in additional to binding the `control`
    property itself).

PR Close #63773
2025-10-04 13:21:55 -07:00
Alan Agius
b725af9924 docs: add documentation for NG0401 error (#63947)
PR Close #63947
2025-09-19 17:01:20 +00:00
Matthieu Riegler
fec7c288e9 fix(core): Error on invalid APP_ID (#63252)
An invalid APP_ID could be responsible to generating broken CSS selectors. (eg `:` is an example for a character that breaks a selector by being a separator for pseudo-selectors.)
We now throw an error if the provided value is not alphanumerical

PR Close #63252
2025-09-19 15:00:10 +00:00
Paul Gschwendtner
648bbb097e fix(core): properly recognize failed fetch responses when loading external resources in JIT (#62992)
Currently when loading external resources in JIT, when `fetch` fails,
the `text` is empty and the component is loading. This hides the actual
underlying fetch error. We should properly detect this and error out.

PR Close #62992
2025-08-05 10:10:56 +02:00
Jessica Janiuk
6b1f4b9e8b feat(core): add enter and leave animation instructions (#62682)
This adds the instructions to support enter and leave animations on nodes.

PR Close #62682
2025-07-23 09:37:16 -04:00
Joey Perrott
23d58777b4 build: migrate to new toolchain usage for api goldens (#62688)
Migrate api golden usage to be based on rules_js toolchain implementation

PR Close #62688
2025-07-17 18:13:42 -04:00
arturovt
e7656b84b2 refactor(core): drop rxResource error messages (#61565)
Drops `rxResource` error messages in production and replaces with error codes.

PR Close #61565
2025-05-21 12:42:59 +00:00
arturovt
2fe8f1a9de refactor(core): drop component factory error in production (#60601)
Drops component factory error in production. Couldn't capture it before because of `throw Error` (without `new`).

PR Close #60601
2025-04-01 13:12:34 +00:00
Andrew Kushnir
152261cd34 refactor(core): produce a message about @defer behavior when HMR is enabled (#60533)
When the HMR is enabled in Angular, all `@defer` block dependencies are loaded
eagerly, instead of waiting for configured trigger conditions. From the DX perspective,
it might be seen as an issue when all dependencies are being loaded eagerly. This commit
adds a logic to produce a message into the console to provide more info for developers.

PR Close #60533
2025-03-28 15:00:32 +00:00
arturovt
aa8dff80ba refactor(core): drop getNgModuleDef error message in production (#60082)
Drops `getNgModuleDef` error message in production and replaces it with an error code.

PR Close #60082
2025-03-05 17:11:06 +00:00
Kristiyan Kostadinov
3459faadbf fix(core): do not allow setInput to be used with inputBinding (#60137)
Calling `setInput` while the component already has an `inputBinding` active can lead to inconsistent state. These changes add an error that will be thrown if that's the case.

PR Close #60137
2025-03-03 22:04:49 +00:00
Kristiyan Kostadinov
a97e10d623 refactor(core): set up underlying input binding symbols (#60137)
Sets up the symbols used to power the upcoming `inputBinding` functionality.

I also fixed that `setDirectiveInput` was incorrectly only allowing strings for the `value` parameter.

PR Close #60137
2025-03-03 22:04:49 +00:00
Samuel Perez
d54deb2ba6 docs: Add NG0750 to errors list (#59265)
This PR adds error NG0750 to Error Encyclopedia.

Update adev/src/content/reference/errors/NG0750.md

Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>

Update adev/src/content/reference/errors/NG0750.md

Co-authored-by: Andrew Kushnir <43554145+AndrewKushnir@users.noreply.github.com>

PR Close #59265
2025-01-06 16:13:36 +00:00
Andrew Kushnir
89db5f734d refactor(core): tree-shake defer block registry (#58424)
This commit updates the code of the incremental hydration feature to make the `DeferBlockRegistry` class tree-shakable. The class is only needed for hydration cases and it should not be included into client bundles for client-only apps.

PR Close #58424
2024-10-31 18:12:03 +01:00
Daniel Jancar
656b5d3e78 fix(core): Re-assign error codes to be within core bounds (<1000) (#53455)
`RUNTIME_DEPS_INVALID_IMPORTED_TYPE` is now 980
`RUNTIME_DEPS_ORPHAN_COMPONENT` is now 981

PR Close #53455
2024-10-07 08:21:13 -07:00
Kristiyan Kostadinov
bbe39c1738 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:31 -07:00
Matthieu Riegler
ce8853e5af 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:00 -07:00
Kristiyan Kostadinov
fb351300c3 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
Renamed from goldens/public-api/core/errors.md (Browse further)