Skip to content

Commit

Permalink
chore(repl): avoid duplicate formatter mounts (#10472)
Browse files Browse the repository at this point in the history
close #10466
  • Loading branch information
baiwusanyu-c committed Jul 11, 2024
1 parent de174e1 commit 23cd614
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/runtime-core/src/customFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function initCustomFormatter() {
// custom formatter for Chrome
// https://www.mattzeunert.com/2016/02/19/custom-chrome-devtools-object-formatters.html
const formatter = {
__vue_custom_formatter: true,
header(obj: unknown) {
// TODO also format ComponentPublicInstance & ctx.slots/attrs in setup
if (!isObject(obj)) {
Expand Down
8 changes: 7 additions & 1 deletion packages/sfc-playground/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,13 @@ onMounted(() => {
:preview-options="{
customCode: {
importCode: `import { initCustomFormatter } from 'vue'`,
useCode: `initCustomFormatter()`,
useCode: `if (window.devtoolsFormatters) {
const index = window.devtoolsFormatters.findIndex((v) => v.__vue_custom_formatter)
window.devtoolsFormatters.splice(index, 1)
initCustomFormatter()
} else {
initCustomFormatter()
}`,
},
}"
/>
Expand Down

0 comments on commit 23cd614

Please sign in to comment.