mirror of https://github.com/vuejs/core.git
fix(devtools): use cleanupBuffer instead of modifying _buffer (#6812)
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
This commit is contained in:
parent
824174915f
commit
35a113eda4
|
@ -28,7 +28,11 @@ interface DevtoolsHook {
|
||||||
once: (event: string, handler: Function) => void
|
once: (event: string, handler: Function) => void
|
||||||
off: (event: string, handler: Function) => void
|
off: (event: string, handler: Function) => void
|
||||||
appRecords: AppRecord[]
|
appRecords: AppRecord[]
|
||||||
_buffer: any[][]
|
/**
|
||||||
|
* Added at https://github.com/vuejs/devtools/commit/f2ad51eea789006ab66942e5a27c0f0986a257f9
|
||||||
|
* Returns wether the arg was buffered or not
|
||||||
|
*/
|
||||||
|
cleanupBuffer?: (matchArg: unknown) => boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export let devtools: DevtoolsHook
|
export let devtools: DevtoolsHook
|
||||||
|
@ -109,18 +113,14 @@ const _devtoolsComponentRemoved = /*#__PURE__*/ createDevtoolsComponentHook(
|
||||||
export const devtoolsComponentRemoved = (
|
export const devtoolsComponentRemoved = (
|
||||||
component: ComponentInternalInstance
|
component: ComponentInternalInstance
|
||||||
) => {
|
) => {
|
||||||
if (devtools && devtools._buffer.length) {
|
if (
|
||||||
let wasBuffered = false
|
devtools &&
|
||||||
devtools._buffer = devtools._buffer.filter(item => {
|
typeof devtools.cleanupBuffer === 'function' &&
|
||||||
if (item.some(arg => arg === component)) {
|
// remove the component if it wasn't buffered
|
||||||
wasBuffered = true
|
!devtools.cleanupBuffer(component)
|
||||||
return false
|
) {
|
||||||
}
|
_devtoolsComponentRemoved(component)
|
||||||
return true
|
|
||||||
})
|
|
||||||
if (wasBuffered) return
|
|
||||||
}
|
}
|
||||||
_devtoolsComponentRemoved(component)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
|
function createDevtoolsComponentHook(hook: DevtoolsHooks) {
|
||||||
|
|
Loading…
Reference in New Issue