The render phases section said phases are specified by passing an object
with a `phase` property to `afterRender` or `afterNextRender`. `afterRender`
was renamed to `afterEveryRender` and the `phase` option no longer exists;
the example shows the spec object accepted by `afterRenderEffect`.
Also fix `nativeElement` being called as a function in the chart example.
(cherry picked from commit 4fa5ce03f0)
The "After" example for `backwardsCompatibleConstructors` imports only
`Component` while its class body calls `inject(MyService)`. The migration
adds `inject` to the `@angular/core` import itself, so the example never
matched its output. The schematic README has the same gap, and its own
first example references `TOKEN` while importing `DI_TOKEN`.
The same block also carried a markdown-escaped doc comment,
`/\*_ ... _/`, and a property sitting outside the class indentation.
`26fed34e0e` introduced both by running prettier over the page while the
snippets were still `<docs-code>` elements, where `**` reads as emphasis.
`caaa5ec8e6` re-indented five of the six blocks when it converted them to
fenced code, and `3731f07579` restored the escaped comment. Prettier skips
a fence it cannot parse, which is why `6270bba056` normalized every other
block on the page and left this one untouched.
Repairing the comment brings the block back under the formatter, so its
imports and indentation now follow `bracketSpacing: false` like the rest
of the page.
(cherry picked from commit 1087257bb5)
The "After" example imports `provideLocationMocks` and `SpyLocation` from
`@angular/common/testing` in two separate statements. The migration adds
`provideLocationMocks` to the existing import, so the output is a single
statement.
(cherry picked from commit 79c9df49f1)
The README described a migration that does not exist. It claimed
standalone tests move to `provideRouter([...])` and that a routeless
`RouterTestingModule` becomes `RouterModule.forRoot([])`; the schematic
produces `RouterModule.forRoot(routes)` and a bare `RouterModule`.
It also listed three files that are not in the directory, said the
migration runs during `ng update` when it is not registered in
`migrations.json`, and gave `--migrate-only router-testing-to-provide-router`
as the command. The schematic is registered as
`router-testing-module-migration` with no alias, and takes a `path` option
that went undocumented.
Rewritten against the schematic and its specs, following the shape of the
other `ng-generate` READMEs. It now also records that only `*.spec.ts`
files are migrated, that router options survive the move to `forRoot`, and
that `RouterModule` lands at the end of the `imports` array.
(cherry picked from commit f28519af1f)
The collection described the schematic as replacing `RouterTestingModule`
with `provideRouter()`. It replaces it with `RouterModule`, or
`RouterModule.forRoot()` when routes are present, and says so itself when
it finishes.
This string is what `ng generate @angular/core --help` prints.
(cherry picked from commit 6f7ace18eb)
The home page code block created a new Promise in a `computed` whenever
the code, language or theme changed, and unwrapped it with the `async`
pipe.
Load the highlighted code with `resource()` instead. Its params track the
code, language and theme, so the code is highlighted again when any of
them changes, and the template reads the value directly. This removes
the last `AsyncPipe` usage in adev.
Unlike the `async` pipe, `resource()` tracks its loading as pending work,
so the application is only considered stable once the code has been
highlighted.
Add a spec covering the initial highlight, theme changes and the
language input.
(cherry picked from commit d7717e2efc)
Previously, empty-path outlet groups in a request URL (such as `x:/(detail:2)`,
`///(detail:2)`, or `x:/()`) were allowed to match without a corresponding
route for that outlet name in the route configuration:
1. `processChildren` called `processSegmentGroup` for each child outlet,
which immediately delegated any zero-segment group with children back to
`processChildren` against the same parent `config` and `parentRoute`
without matching a route. Calling `processSegment` directly in
`processChildren` ensures only the root `UrlSegmentGroup` short-circuits
to `processChildren`.
2. `processSegmentAgainstRoute` allowed named outlets to pierce empty-path
routes for other outlets even when the route had no children to pierce into
or the URL segment group had no segments or children to pierce with.
3. `matchSegmentAgainstRoute` branched into `processChildren` or returned a
completed leaf match before `getOutlet(route) === outlet` was satisfied,
and did not require a descendant `TreeNode` match when piercing an
empty-path route for a different outlet.
4. `noLeftoversInUrl` only checked `!segmentGroup.children[outlet]` rather
than `!segmentGroup.hasChildren()`, allowing unmatched zero-segment outlet
groups with child outlets for other names to be treated as having no
leftovers instead of throwing `NoMatch`.
Together, these allowed crafted URLs with unconfigured zero-segment outlet
groups to fan out across empty-path routes (#70932) or repeatedly evaluate
guards and construct duplicate route snapshot subtrees across sibling outlets
(#70997). Requiring every child segment group to match a route for its outlet
before unwrapping children or completing a match prevents the invalid matches
at the source.
Fixes#70932Fixes#70997
(cherry picked from commit b6bf6504ad)
Previously, resolveUrl only checked whether the raw URL string started with '//' before WHATWG URL resolution. When given an input such as '/.//evil.test', WHATWG dot-segment normalization popped the leading '/.', leaving a pathname starting with '//'. This corrupted ServerPlatformLocation and led to protocol-relative open redirects in SSR.
Now, resolveUrl also verifies that the normalized URL pathname does not start with '//' when allowProtocolRelative is false.
Fixes#71076
(cherry picked from commit d7d81e189d)
Before, when hydration couldn't find a server-rendered element, the error
only gave a tag name and a raw tNode index (e.g. `tNode #27`), which is
meaningless without dev-mode source maps. Now it resolves the enclosing
component's host element and includes it in the message, so there's
actually something to search the codebase for.
lView[HOST] covers the normal case. Embedded views (from `@if`/`@for`)
don't have a host of their own, so we fall back to
lView[DECLARATION_COMPONENT_VIEW]?.[HOST].
The descriptive message stays dev-mode only, as usual for RuntimeError
messages, so it's stripped from production bundles.
(cherry picked from commit 93d59c5e7c)
In @types/d3-selection >= 3.0.12, listener callbacks for mouseover and mouseout
events are strongly typed to receive MouseEvent. Because PointerEvent is a
subtype of MouseEvent, typing the listener parameter as PointerEvent causes
a TypeScript compilation error.
Update nodeMouseoverListeners and nodeMouseoutListeners in GraphRenderer and the
corresponding D3 event handlers in TreeVisualizer to use MouseEvent.
(cherry picked from commit 03795a9f5d)
NgOptimizedImage declares a `srcset` input, so a `[srcset]="..."` binding
is captured by the directive and never reaches the `<img>` element. The
directive only reads that input for a conflict check, so with
`disableOptimizedSrcset` the image ended up with no `srcset` at all. The
only way to set one was `[attr.srcset]`.
Now, when `disableOptimizedSrcset` is set and the directive isn't
generating its own srcset, the value from the `[srcset]` binding is
written back to the element.
Fixes#49335
(cherry picked from commit 2cecc4aa60)
The previous allowlist only permitted image/*, video/*, and audio/*,
which broke internal tests using data:application/octet-stream.
Extend the allowlist to include common non-executable MIME types:
font/*, application/octet-stream, application/pdf, application/json,
text/plain, and text/csv. All executable types (text/html, text/javascript,
application/javascript, etc.) remain blocked.
This maintains the allowlist architecture (safe by default) while
covering legitimate data: URL use cases.
(cherry picked from commit 2b89a3ba5a)
The URL sanitizer previously only blocked `javascript:` URLs via a
negative lookahead. This left other potentially dangerous URL schemes
unblocked, including `data:text/html` (which can execute scripts in
some environments), `vbscript:` (script execution in legacy IE), and
bare `data:` URIs with no explicit media type.
This change extends the URL sanitizer to also block:
- `vbscript:` URLs
- `data:` URLs except for safe media subtypes (image/*, video/*, audio/*)
Safe media data: URIs (e.g. `data:image/png;base64,...`) continue to be
allowed as they are commonly used for inline images and do not execute
scripts when loaded via `<img src>`.
This resolves a longstanding TODO in html_sanitizer.ts to special-case
`data:image/` URIs, which has been open since the sanitizer was first
written.
Applications that rely on non-media `data:` URLs (e.g. `data:text/plain`
or `data:application/pdf`) in sanitized contexts should use
`bypassSecurityTrustUrl()` to explicitly mark them as trusted.
(cherry picked from commit e96936a57f)
controlFlowPreventingContentProjection (NG8011) and unusedLetDeclaration (NG8112) can be
configured under extendedDiagnostics.checks, but neither had a details page. The NG8112 message
links to extended-diagnostics/NG8112, which currently resolves to the angular.dev home page.
Add a page for each. NG8112 goes under extended-diagnostics like the other configurable checks.
NG8011 is in the 80xx range of ErrorCode, which is for compiler errors documented under
adev/src/content/reference/errors, so its code is flipped to -8011 to match every other
documented code in that decade, which is what makes the compiler add the guide link, and its page
goes under errors instead.
(cherry picked from commit a32cd1ad7f)
Ensure WebContainer out-of-memory handling only transitions to the error state once, so the sandbox counter is decremented a single time even if the same output is observed by multiple streams. Add regression coverage for the cleanup path.
(cherry picked from commit 7dcedd4e16)
The migration already records skipped inputs through markFieldIncompatible. Drop the write-only Set and its unused type import.
(cherry picked from commit 81baab42c6)
`HttpClient` split `reportProgress` into `reportUploadProgress` and
`reportDownloadProgress`, but `httpResource` still passed its
`reportProgress` option to the deprecated `reportProgress` of
`HttpRequest`.
The `progress` signal of `httpResource` only tracks download events, so
`reportProgress` there already means download progress. Forward it as
`reportDownloadProgress` instead of adding a new option.
(cherry picked from commit f458730d37)
The progress bar listened to `NavigationStart` on `router.events`, started
a timer to show the bar after `PROGRESS_BAR_DELAY`, and used `switchMap`
to wait for the first `NavigationEnd`/`Cancel`/`Skipped`/`Error` event to
clear the timer and complete the bar.
Replace this with a single `effect` on the router's `currentNavigation`
signal: while a navigation is ongoing the effect schedules the timer, and
its cleanup, which runs when the navigation ends or is superseded, clears
the timer and completes the bar.
Replace the disabled spec with specs that keep a navigation pending
through a resolver, covering slow, fast and canceled navigations.
(cherry picked from commit 24e11ad41b)
The v21 and v22 event images were listed as separate asset entries
(`src/assets/images/v21-event` and `src/assets/images/v22-event`) next to
`src/assets`, which already contains them. They were added when the
images were moved into their own Bazel packages, but the Bazel targets in
`APPLICATION_FILES` are what place the files under `src/assets`; the
extra entries only copy the same files to the same output location
(`assets/images/v2x-event/`) a second time.
The unit-test builder reuses these assets and copies them into the test
output. Since the first copy is read-only in the Bazel sandbox, the
duplicate copy fails with `EACCES: permission denied, copyfile`, which
breaks running `//adev:test` locally.
Remove the redundant entries. The production build output is unchanged
(all non-HTML files, including the event images, are byte-identical) and
`//adev:test` runs again without errors.
(cherry picked from commit b7280d0263)
The README documents only the `providedIn: 'root'` case, so it omits the
`@Service({autoProvided: false})` output that a class declared without
options gets. Its inheritance limitation also predates 792edaba48, which
taught the schematic to walk base classes.
(cherry picked from commit 13c3d32643)
`ng generate @angular/core:service` shipped in 22.1 without a documentation
page, so it is missing from the migrations index.
The page is written from the schematic rather than from its README, which
documents only the `providedIn: 'root'` case. A class declared without
options also migrates, to `@Service({autoProvided: false})`, and that is the
less obvious of the two outcomes.
It also records behavior the README leaves out: the constructor check stops
at the closest ancestor declared in your own source, the migration covers
test files as well, and a file with both migrated and skipped classes keeps
both the `Injectable` and the `Service` import.
Fixes#71035
(cherry picked from commit c49a12a07a)