Skip to content

Commit 17f0e6d

Browse files
committed
fix(vue2): app record id not found, closes #1699
1 parent 765d0e0 commit 17f0e6d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ async function capture (instance, index?: number, list?: any[]): Promise<Compone
223223
// instance._uid is not reliable in devtools as there
224224
// may be 2 roots with same _uid which causes unexpected
225225
// behaviour
226-
instance.__VUE_DEVTOOLS_UID__ = getUniqueId(instance)
226+
instance.__VUE_DEVTOOLS_UID__ = getUniqueId(instance, appRecord)
227227

228228
// Dedupe
229229
if (captureIds.has(instance.__VUE_DEVTOOLS_UID__)) {

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

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { getComponentName } from '@vue-devtools/shared-utils'
2+
import { AppRecord } from '@vue-devtools/app-backend-api'
23

34
export function isBeingDestroyed (instance) {
45
return instance._isBeingDestroyed
@@ -32,8 +33,14 @@ export function getRenderKey (value): string {
3233
/**
3334
* Returns a devtools unique id for instance.
3435
*/
35-
export function getUniqueId (instance): string {
36+
export function getUniqueId (instance, appRecord?: AppRecord): string {
3637
if (instance.__VUE_DEVTOOLS_UID__ != null) return instance.__VUE_DEVTOOLS_UID__
37-
const rootVueId = instance.$root.__VUE_DEVTOOLS_APP_RECORD_ID__
38+
let rootVueId = instance.$root.__VUE_DEVTOOLS_APP_RECORD_ID__
39+
if (!rootVueId && appRecord) {
40+
rootVueId = appRecord.id
41+
}
42+
if (!rootVueId) {
43+
console.error('No app record id found for instance', instance)
44+
}
3845
return `${rootVueId}:${instance._uid}`
3946
}

0 commit comments

Comments
 (0)