Skip to content

Commit 35a113e

Browse files
posvaantfu
andauthored
fix(devtools): use cleanupBuffer instead of modifying _buffer (#6812)
Co-authored-by: Anthony Fu <[email protected]>
1 parent 8241749 commit 35a113e

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

packages/runtime-core/src/devtools.ts

+12-12
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ interface DevtoolsHook {
2828
once: (event: string, handler: Function) => void
2929
off: (event: string, handler: Function) => void
3030
appRecords: AppRecord[]
31-
_buffer: any[][]
31+
/**
32+
* Added at https://github.com/vuejs/devtools/commit/f2ad51eea789006ab66942e5a27c0f0986a257f9
33+
* Returns wether the arg was buffered or not
34+
*/
35+
cleanupBuffer?: (matchArg: unknown) => boolean
3236
}
3337

3438
export let devtools: DevtoolsHook
@@ -109,18 +113,14 @@ const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
109113
export const devtoolsComponentRemoved = (
110114
component: ComponentInternalInstance
111115
) => {
112-
if (devtools && devtools._buffer.length) {
113-
let wasBuffered = false
114-
devtools._buffer = devtools._buffer.filter(item => {
115-
if (item.some(arg => arg === component)) {
116-
wasBuffered = true
117-
return false
118-
}
119-
return true
120-
})
121-
if (wasBuffered) return
116+
if (
117+
devtools &&
118+
typeof devtools.cleanupBuffer === 'function' &&
119+
// remove the component if it wasn't buffered
120+
!devtools.cleanupBuffer(component)
121+
) {
122+
_devtoolsComponentRemoved(component)
122123
}
123-
_devtoolsComponentRemoved(component)
124124
}
125125

126126
function createDevtoolsComponentHook(hook: DevtoolsHooks) {

0 commit comments

Comments
 (0)