Routed component host created in SVG namespace after an <svg> sibling (22.1.4)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- angular, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia con la modifica di createHostElement() di Angular core nel commit 2ab5ff5 e riproduci il problema usando la riproduzione minima collegata. Traccia la propagazione del namespace per un router-outlet creato all'interno di un @if dopo un SVG precedente; il lavoro è completo quando l'host sottoposto a routing usa il namespace HTML e viene renderizzato con il layout normale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Which @angular/* package(s) are the source of the bug?
core
Is this a regression?
Yes
Description
When a <router-outlet> sits inside an @if block and any <svg> appears
earlier in the same template, the routed component's host element is created in
the SVG namespace. The <svg> is closed and is only a preceding sibling — the
outlet is not nested inside it.
An SVG-namespaced element gets no CSS box in HTML layout, so the routed view
computes to 0x0. The markup is fully present and correct in the DOM, every
computed style looks right, and no error or warning is logged — the page is
simply blank.
The @if is required. Without it the same <svg> causes no problem:
<svg> earlier in template |
outlet inside @if |
host namespace | result |
|---|---|---|---|
| yes | no | HTML | renders |
| yes | yes | SVG | 0x0, blank |
Nesting the <svg> inside another element (e.g. a <button>) makes no
difference; the @if is the deciding factor. Wrapping the outlet in any HTML
element inside the @if restores the HTML namespace and works around it.
Bisected to 2ab5ff5 ("fix(core): preserve namespace for dynamic component
hosts"), which changed createHostElement():
// 22.1.3
const namespace = tagName === 'svg' ? SVG_NAMESPACE : tagName === 'math' ? MATH_ML_NAMESPACE : null;
// 22.1.4
const namespace = tagName === 'svg' ? SVG_NAMESPACE : tagName === 'math' ? MATH_ML_NAMESPACE : hostElementNamespace;
Is this the intended consequence of that change? The outlet is not nested inside
the <svg> — the element is closed before the @if block begins — so it is not
obvious that the SVG namespace should reach the routed host here.
Please provide a link to a minimal reproduction of the bug
https://github.com/hypnotoad08/angular-svg-namespace-repro
Please provide the exception or error you saw
None. There is no exception and no console warning.
Please provide the environment you discovered this bug in (run ng version)
Angular CLI : 22.1.6
Angular : 22.1.4
Node.js : 24.20.0
Package Manager : npm 11.19.0
Operating System : win32 x64
┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/build │ 22.1.6 │ ^22.1.5 │
│ @angular/cli │ 22.1.6 │ ^22.1.5 │
│ @angular/common │ 22.1.4 │ ^22.1.3 │
│ @angular/compiler │ 22.1.4 │ ^22.1.3 │
│ @angular/compiler-cli │ 22.1.4 │ ^22.1.3 │
│ @angular/core │ 22.1.4 │ ^22.1.3 │
│ @angular/forms │ 22.1.4 │ ^22.1.3 │
│ @angular/platform-browser │ 22.1.4 │ ^22.1.3 │
│ @angular/router │ 22.1.4 │ ^22.1.3 │
│ rxjs │ 7.8.2 │ ^7.8.2 │
│ typescript │ 6.0.3 │ ~6.0.3 │
│ vitest │ 4.1.11 │ ^4.1.10 │
└───────────────────────────┴───────────────────┴───────────────────┘
Anything else?
No response
- Lingua principale
- TypeScript
- Stelle
- 101k
- Fork
- 28.1k
- Merge medio
- 1g 18h
- PR unite (30g)
- 254
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di angular/angular
-
area: docs
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
area: forms forms: signals
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
area: docs gemini-triaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
area: forms forms: signals
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
area: docs area: forms
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
Tutte le issue di angular/angular
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
Add: Star Sports 2 Telugu HD Apertacheck:passed streams:add
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100