Skip to content

Commit 23cd614

Browse files
authored
chore(repl): avoid duplicate formatter mounts (#10472)
close #10466
1 parent de174e1 commit 23cd614

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

packages/runtime-core/src/customFormatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export function initCustomFormatter() {
2424
// custom formatter for Chrome
2525
// https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
2626
const formatter = {
27+
__vue_custom_formatter: true,
2728
header(obj: unknown) {
2829
// TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
2930
if (!isObject(obj)) {

packages/sfc-playground/src/App.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ onMounted(() => {
129129
:preview-options="{
130130
customCode: {
131131
importCode: `import { initCustomFormatter } from 'vue'`,
132-
useCode: `initCustomFormatter()`,
132+
useCode: `if (window.devtoolsFormatters) {
133+
const index = window.devtoolsFormatters.findIndex((v) => v.__vue_custom_formatter)
134+
window.devtoolsFormatters.splice(index, 1)
135+
initCustomFormatter()
136+
} else {
137+
initCustomFormatter()
138+
}`,
133139
},
134140
}"
135141
/>

0 commit comments

Comments
 (0)