mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
refactor(devtools): fix reading resolutionPath (#60403)
Sometimes `forest` can be empty if the provided roots are empty, and was leading to a "Cannot read `resolutionPath` of `undefined`" error. Now we check the forest has a tree in it before looking up `resolutionPath`. There might be a separate issue with the fact that the backend script likely shouldn't be emitting an empty forest in the first place. However we already check that a resolution path exists at all, so I think it's fair to also check that a tree was provided. We can separately look into making sure the backend is emitting valid data. PR Close #60403
This commit is contained in:
committed by
Pawel Kozlowski
parent
82fb14e600
commit
9dffdd744d
@@ -222,13 +222,15 @@ const getRoutes = (messageBus: MessageBus<Events>) => {
|
||||
initializeOrGetDirectiveForestHooks().getIndexedDirectiveForest(),
|
||||
ngDebugDependencyInjectionApiIsSupported(),
|
||||
);
|
||||
if (forest.length === 0) return;
|
||||
|
||||
const rootInjector = (forest[0].resolutionPath ?? []).find((i) => i.name === 'Root');
|
||||
if (rootInjector) {
|
||||
const route = getRouterConfigFromRoot(rootInjector);
|
||||
if (route) {
|
||||
messageBus.emit('updateRouterTree', [[route]]);
|
||||
}
|
||||
}
|
||||
if (!rootInjector) return;
|
||||
|
||||
const route = getRouterConfigFromRoot(rootInjector);
|
||||
if (!route) return;
|
||||
|
||||
messageBus.emit('updateRouterTree', [[route]]);
|
||||
};
|
||||
|
||||
const getSerializedProviderRecords = (injector: SerializedInjector) => {
|
||||
|
||||
+7
-5
@@ -91,11 +91,13 @@ export class InjectorTreeComponent {
|
||||
|
||||
private init() {
|
||||
this._messageBus.on('latestComponentExplorerView', (view: ComponentExplorerView) => {
|
||||
if (view.forest[0].resolutionPath !== undefined) {
|
||||
this.diDebugAPIsAvailable.set(true);
|
||||
this.rawDirectiveForest = view.forest;
|
||||
this.updateInjectorTreeVisualization(view.forest);
|
||||
}
|
||||
if (view.forest.length === 0) return;
|
||||
|
||||
if (!view.forest[0].resolutionPath) return;
|
||||
|
||||
this.diDebugAPIsAvailable.set(true);
|
||||
this.rawDirectiveForest = view.forest;
|
||||
this.updateInjectorTreeVisualization(view.forest);
|
||||
});
|
||||
|
||||
this._messageBus.on(
|
||||
|
||||
Reference in New Issue
Block a user