Skip to content

Commit

Permalink
fix(vue2): add more null guards
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed Feb 11, 2022
1 parent 29ea4d0 commit f8f457a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/app-backend-vue2/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ export function setupPlugin (api: DevtoolsApi, app: App, Vue) {

api.on.getInspectorTree(payload => {
if (payload.inspectorId === ROUTER_INSPECTOR_ID) {
payload.rootNodes = router.options.routes.map(route => formatRouteNode(router, route, '', payload.filter)).filter(Boolean)
if (router.options.routes) {
payload.rootNodes = router.options.routes.map(route => formatRouteNode(router, route, '', payload.filter)).filter(Boolean)
} else {
console.warn(`[Vue Devtools] No routes found in router`, router.options)
}
}
})

Expand Down Expand Up @@ -392,7 +396,7 @@ function formatStoreForInspectorTree (module, moduleName: string, path: string):
// nested/cart/ -> cart
label: moduleName,
tags: module.namespaced ? [TAG_NAMESPACED] : [],
children: Object.keys(module._children).map((key) =>
children: Object.keys(module._children ?? {}).map((key) =>
formatStoreForInspectorTree(
module._children[key],
key,
Expand Down Expand Up @@ -421,7 +425,7 @@ function extractNameFromPath (path: string) {

function formatStoreForInspectorState (module, getters, path): CustomInspectorState {
const storeState: CustomInspectorState = {
state: Object.keys(module.context.state).map((key) => ({
state: Object.keys(module.context.state ?? {}).map((key) => ({
key,
editable: true,
value: module.context.state[key],
Expand Down

0 comments on commit f8f457a

Please sign in to comment.