Skip to content

Commit 48ae26c

Browse files
authored
fix: support vue-devtools component inspector custom tags breaking change (#332)
1 parent d9ce770 commit 48ae26c

File tree

4 files changed

+27
-25
lines changed

4 files changed

+27
-25
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"@types/jest": "^26.0.14",
6666
"@typescript-eslint/eslint-plugin": "^4.11.0",
6767
"@typescript-eslint/parser": "^4.11.0",
68-
"@vue/devtools-api": "^6.0.0-beta.3",
68+
"@vue/devtools-api": "^6.0.0-beta.5",
6969
"@vue/server-renderer": "^3.0.0",
7070
"algoliasearch": "^4.8.2",
7171
"api-docs-gen": "^0.2.6",

packages/vue-i18n/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"dependencies": {
3737
"@intlify/core-base": "9.0.0-rc.4",
3838
"@intlify/shared": "9.0.0-rc.4",
39-
"@vue/devtools-api": "^6.0.0-beta.3"
39+
"@vue/devtools-api": "^6.0.0-beta.5"
4040
},
4141
"peerDependencies": {
4242
"vue": "^3.0.0"

packages/vue-i18n/src/devtools.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,29 +138,31 @@ function updateComponentTreeDataTags<
138138
Legacy extends boolean
139139
>(
140140
appRecord: AppRecord,
141-
treeData: ComponentTreeNode,
141+
treeData: ComponentTreeNode[],
142142
i18n: _I18n<Messages, DateTimeFormats, NumberFormats, Legacy>
143143
): void {
144-
const instance = appRecord.instanceMap.get(treeData.id)
145-
if (instance && instance.vnode.el.__INTLIFY__) {
146-
// prettier-ignore
147-
const global = i18n.mode === 'composition'
148-
? i18n.global
149-
: (i18n.global as unknown as VueI18nInternal).__composer
150-
// add custom tags local scope only
151-
if (instance.vnode.el.__INTLIFY__ !== global) {
152-
const label =
153-
instance.type.name || instance.type.displayName || instance.type.__file
154-
const tag = {
155-
label: `i18n (${label} Scope)`,
156-
textColor: 0x000000,
157-
backgroundColor: 0xffcd19
144+
// prettier-ignore
145+
const global = i18n.mode === 'composition'
146+
? i18n.global
147+
: (i18n.global as unknown as VueI18nInternal).__composer
148+
for (const node of treeData) {
149+
const instance = appRecord.instanceMap.get(node.id)
150+
if (instance && instance.vnode.el.__INTLIFY__) {
151+
// add custom tags local scope only
152+
if (instance.vnode.el.__INTLIFY__ !== global) {
153+
const label =
154+
instance.type.name ||
155+
instance.type.displayName ||
156+
instance.type.__file
157+
const tag = {
158+
label: `i18n (${label} Scope)`,
159+
textColor: 0x000000,
160+
backgroundColor: 0xffcd19
161+
}
162+
node.tags.push(tag)
158163
}
159-
treeData.tags = [tag]
160164
}
161-
}
162-
for (const node of treeData.children) {
163-
updateComponentTreeDataTags(appRecord, node, i18n)
165+
updateComponentTreeDataTags(appRecord, node.children, i18n)
164166
}
165167
}
166168

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,10 +1424,10 @@
14241424
"@vue/compiler-dom" "3.0.5"
14251425
"@vue/shared" "3.0.5"
14261426

1427-
"@vue/devtools-api@^6.0.0-beta.3":
1428-
version "6.0.0-beta.3"
1429-
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.3.tgz#5a66cc8beed688fe18c272ee7a8bd8ed7e35a54c"
1430-
integrity sha512-iJQhVyWzWIJxYIMjbZpljZQfU4gL2IMD5YQm3HXO8tQRU7RqqnD3f1WHn+vrqvrSvM8Qw2BeNugwdBBmbK8Oxg==
1427+
"@vue/devtools-api@^6.0.0-beta.5":
1428+
version "6.0.0-beta.5"
1429+
resolved "https://registry.yarnpkg.com/@vue/devtools-api/-/devtools-api-6.0.0-beta.5.tgz#722296bb0b93c4d0018b6a2beda1e781a3ff8789"
1430+
integrity sha512-Xik8/zF+cu1lQmhJy2djGudZ2OmSGGB25mjtTIGhMsNN7jvvwnn44kD6qSN22+PdnX6sAK+2EQ51WDCXWmitwg==
14311431

14321432
14331433
version "3.0.4"

0 commit comments

Comments
 (0)