Signal forms are model-driven and do not support pending or uncommitted
values. As a result, non-default `updateOn` options (`blur`, `submit`)
cannot be supported.
This commit adds a dev-mode check in `SignalFormControl` to throw an error
when:
1. An unsupported `updateOn` option is passed directly in options to the
`SignalFormControl` constructor.
2. A non-default `updateOn` option is inherited from a parent `FormGroup`
or `FormArray` via `setParent()`.
Additionally, `SignalFormControl` explicitly overrides `get updateOn()`
to return `'change'`.
(cherry picked from commit 9e99093bfe)
The web worker, service worker and app shell guides still showed `app.component.*` file names and the old root template text. Use the current names (`app.ts`, `app.html`, `app-shell.ts`), the current root template text, and list the files the generated `ngsw-config.json`
actually caches.
(cherry picked from commit cd9d0aea3f)
Adding some feedback based on AI security reports to help guide them towards what is and is not a legitimate vulnerability.
(cherry picked from commit 309eaf6b9b)
Add a "Prerendering" section to the i18n deploy guide for apps built with
`outputMode: "static"`. It describes the per-locale output layout, serving
the source locale from the root with `"subPath": ""`, the lack of
`Accept-Language` redirects without a server, and per-locale not-found pages.
Also add a short section to the locale ID guide on reading the active locale
with `$localize.locale` where `LOCALE_ID` can't be injected.
(cherry picked from commit aaa471b799)
Interpolation renders null and undefined as an empty string instead of
converting them with toString. Attribute bindings remove the attribute for
undefined as well as null. The [class] binding does not drop strings that
are not valid CSS class names, so describe the string form instead.
(cherry picked from commit c35b3ad17b)
This reverts commit be34a108d6.
#71602 relies on `NavigationExtras.focusReset`, which was added in #71595 (`target: minor`) and only merged into `main`. Reverting on `22.2.x` to fix the release branch build.
The API reference filter writes its value to the URL on each change. With
the Navigation API integration, each of these navigations ends with the
browser moving focus to the body, so typing `signal` in the filter leaves
`s` and the other keys go to the page.
Pass `focusReset: 'manual'` next to `scroll: 'manual'`, so focus stays in
the filter field.
(cherry picked from commit 07de4b0234)
`split` is designed to split remaining primary outlet segments alongside
empty-path named outlets (`createChildrenForEmptyPaths` wraps `slicedSegments`
in `res[PRIMARY_OUTLET]`). When piercing an empty-path route to look for a
named outlet among its descendants (`!matchedOnOutlet`), `remainingSegments`
belong to that named outlet rather than `PRIMARY_OUTLET`.
Previously, `split` was called even when `!matchedOnOutlet`, which required
the `isSelfEvaluating` workaround in #67708 to ignore an empty-path route for
the same outlet being evaluated. However, if the pierced empty-path route also
contained another empty-path named outlet sibling (e.g. `tertiary` alongside
`secondary`), `split` still moved `secondary`'s segments into
`children[PRIMARY_OUTLET]` and caused matching to fail.
Skipping `split` when `!matchedOnOutlet` fixes matching when multiple named
outlets exist under an empty-path route and allows removing the `outlet` /
`isSelfEvaluating` workaround from `split`.
Related to #67708
(cherry picked from commit 5048f50268)
The ngclass-to-class migration only looked at object literals, so bindings
like `[ngClass]="'first second'"` and `[ngClass]="['first', 'second']"` were
left untouched even though `[class]` accepts exactly the same shapes. See
`toStylingKeyValueArray` in packages/core/src/render3/instructions/styling.ts,
which handles `string | string[] | Set<string> | {[key: string]: any}`.
Both forms are now forwarded to `[class]` unchanged. Detection goes through
the TypeScript parser rather than matching quotes, so an expression that
merely starts and ends with a quote - a ternary, a concatenation - is not
mistaken for a literal and keeps using NgClass.
An array entry containing whitespace is deliberately left alone: NgClass
splits each entry on whitespace, while `[class]` drops any entry containing a
space (see `classKeyValueArraySet`), so `['a b', 'c']` would silently lose
classes. This mirrors the guard the migration already applies to object keys.
Empty arrays keep going through the existing object-literal path, which maps
them to `[class]=""`, so that output is unchanged.
Emitting the replacement now picks the quote character to match the value
instead of always using double quotes. An expression can only contain a
double quote if it came from a single-quoted attribute, in which case it
contains no single quote, so wrapping it in single quotes is always safe.
That lets `[ngClass]='["a", "b"]'` migrate, and it also fixes the existing
object-literal path, which produced invalid HTML for those attributes:
<div [ngClass]='{"a": isA, "b": isB}'>
<div [class]="{"a": isA, "b": isB}"> <- before
<div [class]='{"a": isA, "b": isB}'> <- after
<div [ngClass]='{active: mode === "on"}'>
<div [class.active]="mode === "on""> <- before
<div [class.active]='mode === "on"'> <- after
String literal values in the object-literal path are now kept as written
instead of having their text re-wrapped in single quotes. Re-wrapping broke
as soon as the text contained a double quote, because the value then clashed
with the single quotes picked for the attribute:
<div [ngClass]='{active: "\"yes\""}'>
<div [class.active]=''"yes"''> <- before
<div [class.active]='"\"yes\""'> <- after
(cherry picked from commit 9ab611de28)
Directives and bindings are not supported on elements inside ICU
expressions, because ICU content is processed at runtime as plain HTML.
Using one anyway, e.g. `<b [title]="title">` inside a plural case, used to
crash with a cryptic `InvalidCharacterError` from `setAttribute`. Since the
ICU attribute allowlist was introduced, such attributes are dropped with a
generic "ignoring unknown attribute name" warning that points to the XSS
security guide, which doesn't tell developers what is actually wrong.
Detect binding-like attribute names (`[prop]`, `(event)`, `*structural`,
`#ref`, `@trigger`) while parsing ICU content and report them in
development mode with a dedicated `NG0700` warning that names the attribute
and the element and explains that only static attributes are allowed
inside ICU cases. The attribute is still ignored, as before.
Fixes#37298
(cherry picked from commit 8523b79bee)
NgOptimizedImage prepends auto to sizes only for lazy-loaded images, and
it always sets decoding to sync on priority images, ignoring an explicit
decoding value. The guide implied both applied to every image.
(cherry picked from commit a2ac9567e0)
Previously, `generate_api_docs(...)` targets lived directly in each
`//packages/**/BUILD.bazel` file (and `render_api_to_html(...)` in
`//tools/manual_api_docs/{blocks,elements}/BUILD.bazel`). Because
`render_api_to_html` validates links against
`//adev/scripts/routes:defined-routes.json`, running wildcard package
builds or tests such as `bazel test //packages/forms/...` pulled in the
`//adev/...` route generation and API manifest dependency graph across
all packages.
Move all framework `generate_api_docs` and manual API `render_api_to_html`
targets into `//adev/src/content/api` alongside `aria`, `cdk`, and `cli`,
leaving only lightweight `files_for_docgen` filegroups in `//packages/...`
and JSON extraction targets in `//tools/manual_api_docs/...`. Remove the
`generate_api_docs` wrapper from `//tools:defaults.bzl` so neither
`//packages/...` nor `//tools/...` loads or depends on `//adev/...`, and
add `//adev/src/content/api:api_docs_test` so `bazel test //adev/...`
explicitly exercises API doc generation and link validation.
(cherry picked from commit 9bbb7c9d46)
The keydown.code.alt.shiftleft example never fires, because Angular adds
the shift modifier to the computed key. Pressing Alt and Left Shift
produces code.alt.shift.shiftleft.
(cherry picked from commit 2e4e1214cc)
The comment said the service installs a CSS transition and listens
for `transitionstart`. Since it was introduced, the service has
installed `@keyframes` animations and listened for `animationstart`.
Describe what the code does, and rename the private
`createTransitionStyle()` to `createAnimationStyle()` to match.
(cherry picked from commit 4570715712)
NG0910 is also thrown for bindings on SVG animation attributes that
could change an `href`, such as `attributeName`, but the page only
described iframe attributes. Describe the error for any element and
list both cases.
Co-authored-by: Matthieu Riegler <[email protected]>
(cherry picked from commit 960a41d93b)
The `debounced()` cycle-error spec had no expectations, and it ended
before the debounced load started, because `debounced()` registers no
pending task. Check the loads and the field's pending and valid state
across the debounce.
The `validateAsync` orphan spec registered abort listeners but never
checked them. Check that removing an item aborts its in-flight load
and leaves the other item's load running.
(cherry picked from commit 95b9765737)