Skip to content

Commit de7eb49

Browse files
committed
feat: introduce data-v-inspector-ignore prop
1 parent 91fdaf4 commit de7eb49

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

packages/core/src/Overlay.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ const hostOpts = inspectorOptions.serverOptions?.host
77
const host = hostOpts && hostOpts !== true ? hostOpts : importMetaUrl?.hostname
88
const port = inspectorOptions.serverOptions?.port ?? importMetaUrl?.port
99
const baseUrl = isClient ? `${protocol}//${host}:${port}` : ''
10+
11+
const KEY_DATA = 'data-v-inspector-options'
12+
const KEY_IGNORE = 'data-v-inspector-ignore'
13+
1014
export default {
1115
name: 'VueInspectorOverlay',
1216
data() {
@@ -27,6 +31,7 @@ export default {
2731
line: 0,
2832
column: 0,
2933
},
34+
KEY_IGNORE,
3035
}
3136
},
3237
computed: {
@@ -123,17 +128,25 @@ export default {
123128
getTargetNode(e) {
124129
const splitRE = /(.+):([\d]+):([\d]+)$/
125130
const path = e.path ?? e.composedPath()
126-
const targetNode = path?.find(node => node?.hasAttribute?.('data-v-inspector-options'))
127-
if (this.isChildOf(targetNode, this.$refs.containerRef) || !targetNode) {
131+
if (!path) {
132+
return {
133+
targetNode: null,
134+
params: null,
135+
}
136+
}
137+
const ignoreIndex = path.findIndex(node => node?.hasAttribute?.(KEY_IGNORE))
138+
const targetNode = path.slice(ignoreIndex + 1).find(node => node?.hasAttribute?.(KEY_DATA))
139+
if (!targetNode) {
128140
return {
129141
targetNode: null,
130142
params: null,
131143
}
132144
}
133-
const [_, file, line, column] = targetNode?.getAttribute?.('data-v-inspector-options')?.match(splitRE)
145+
const match = targetNode.getAttribute(KEY_DATA)?.match(splitRE)
146+
const [_, file, line, column] = match || []
134147
return {
135148
targetNode,
136-
params: targetNode
149+
params: match
137150
? {
138151
file,
139152
line,
@@ -207,7 +220,7 @@ export default {
207220
</script>
208221
209222
<template>
210-
<div>
223+
<div v-bind="{ [KEY_IGNORE]: 'true' }">
211224
<div
212225
v-if="containerVisible"
213226
ref="containerRef"
@@ -254,7 +267,7 @@ export default {
254267
</a>
255268
</div>
256269
<!-- Overlay -->
257-
<template v-if="overlayVisible">
270+
<template v-if="overlayVisible && linkParams">
258271
<div
259272
ref="floatsRef"
260273
class="vue-inspector-floats vue-inspector-card"

0 commit comments

Comments
 (0)