Bug: DevTools DOM lookup cannot find React-managed title, meta and non-resource link elements
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Ferma
- Stack tecnologico
- javascript, react
- Ambito
- developer-experience, frontend
Direzione di ricerca
Inizia in packages/react-devtools-facade/src/DevToolsFacadeTreeTools.js, concentrandoti su getHostInstanceForFiber e sul percorso di ricerca HostHoistable. Esegui l'entry point ufficiale dei test di build di DevTools e verifica che gli elementi title, meta e link non associati a risorse vengano risolti tramite la ricerca nel DOM, mentre il controllo associato a una risorsa continui a superare il test.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
getComponentByHostInstance reports that a React-managed metadata element is not managed by React. The same element is present and inspectable by UID in getComponentTree, so DOM-based and UID-based inspection disagree.
Affected version
Current react/react main: 019019be403c3269e15b8d7ebefb57d30f84086b (React source version 19.3.0). The source includes react-devtools-cdt-mcp 0.1.0; this report is verified against the source baseline.
Steps To Reproduce
// Install the facade before initializing React (as documented).
const facade = installFacade();
const tools = createTools(facade);
act(() => root.render(<meta name="facade-test" content="value" />));
const element = document.head.querySelector('meta[name="facade-test"]');
console.log(tools.getComponentByHostInstance(element));
// {error: 'Host instance is not managed by React'}
A runnable repository regression test is included in the linked fix PR.
The current behavior
Lookup fails for title/meta and non-resource link instances. Resource-backed style elements follow a different storage path and can be found.
The expected behavior
A React-managed hoistable DOM element should resolve to its host component, with the same UID and props returned by component-tree inspection.
Root cause and impact
getHostInstanceForFiber handles HostHoistable only through memoizedState.instance. Non-resource hoistables have null memoizedState and store their DOM instance in stateNode (see the HostHoistable commit path).
Source: packages/react-devtools-facade/src/DevToolsFacadeTreeTools.js.
Severity assessment: Medium. getComponentByHostInstance reports that a React-managed metadata element is not managed by React. The same element is present and inspectable by UID in getComponentTree, so DOM-based and UID-based inspection disagree.
Verification
Before: the non-resource hoistable regression fails and the resource-backed control passes through the official DevTools build test entry. After: DevToolsFacade and DevToolsCdtMcp pass 132/132 tests. Prettier, ESLint and Flow pass.
Duplicate check
Searched all Issue/PR states for getHostInstanceForFiber, facade meta and hoistable DevTools. #36820 introduced this lookup; #30584/#30590 and #35741 concern the separate full DevTools renderer backend and its node mapping/lifecycle. No equivalent facade fallback was found.
Compatibility and risks
The resource-record lookup keeps its existing priority. The fallback matches the reconciler stateNode storage for non-resource hoistables. This changes inspection only, not rendering or resource lifetime.
- Lingua principale
- JavaScript
- Stelle
- 251k
- Fork
- 51.4k
- Merge medio
- 2g 1h
- PR unite (30g)
- 51
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 react/react
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·
-
ecosystem wording
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
matrix-org/matrix.org#3649 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
vadimdemedes/ink#1029 ·