Skip to content

Commit ca87567

Browse files
authored
fix: Call api.visitComponentTree in Vue2's backend api (vuejs#1524)
1 parent aee3f51 commit ca87567

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

  • packages/app-backend-vue2/src/components

packages/app-backend-vue2/src/components/tree.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AppRecord, BackendContext } from '@vue-devtools/app-backend-api'
1+
import { AppRecord, BackendContext, DevtoolsApi } from '@vue-devtools/app-backend-api'
22
import { classify } from '@vue-devtools/shared-utils'
33
import { ComponentTreeNode } from '@vue/devtools-api'
44
import { getInstanceOrVnodeRect } from './el'
@@ -8,6 +8,7 @@ export let instanceMap: Map<any, any>
88
export let functionalVnodeMap: Map<any, any>
99

1010
let appRecord: AppRecord
11+
let api: DevtoolsApi
1112

1213
const consoleBoundInstances = Array(5)
1314

@@ -53,6 +54,7 @@ export function getComponentParents (instance, ctx: BackendContext) {
5354

5455
function initCtx (ctx: BackendContext) {
5556
appRecord = ctx.currentAppRecord
57+
api = ctx.api
5658
if (!appRecord.meta.instanceMap) {
5759
appRecord.meta.instanceMap = new Map()
5860
}
@@ -175,7 +177,7 @@ function capture (instance, index?: number, list?: any[]): ComponentTreeNode {
175177
// router-view has both fnContext and componentInstance on vnode.
176178
: instance.componentInstance ? [capture(instance.componentInstance)] : []).filter(Boolean)
177179

178-
return {
180+
const treeNode = {
179181
uid: functionalId,
180182
id: functionalId,
181183
tags: [
@@ -192,6 +194,12 @@ function capture (instance, index?: number, list?: any[]): ComponentTreeNode {
192194
inactive: false,
193195
isFragment: false // TODO: Check what is it for.
194196
}
197+
return api.visitComponentTree(
198+
instance,
199+
treeNode,
200+
filter,
201+
appRecord?.options?.app
202+
)
195203
}
196204
// instance._uid is not reliable in devtools as there
197205
// may be 2 roots with same _uid which causes unexpected
@@ -266,7 +274,12 @@ function capture (instance, index?: number, list?: any[]): ComponentTreeNode {
266274
backgroundColor: 0xff8344
267275
})
268276
}
269-
return ret
277+
return api.visitComponentTree(
278+
instance,
279+
ret,
280+
filter,
281+
appRecord?.options?.app
282+
)
270283
}
271284

272285
/**

0 commit comments

Comments
 (0)