|
1 | 1 | import path from 'path' |
| 2 | +import { CustomState } from '@vue/devtools-api' |
2 | 3 | import { stringifyCircularAutoChunks, parseCircularAutoChunks } from './transfer' |
3 | 4 | import { |
4 | 5 | getInstanceMap, |
5 | 6 | getCustomInstanceDetails, |
6 | 7 | getCustomRouterDetails, |
7 | 8 | getCustomStoreDetails, |
8 | | - isVueInstance, |
9 | | - backendInjections |
| 9 | + isVueInstance |
10 | 10 | } from './backend' |
11 | 11 | import SharedData from './shared-data' |
12 | 12 | import { isChrome, target } from './env' |
@@ -196,6 +196,8 @@ function replacer (key) { |
196 | 196 | return encodeCache.cache(val, () => getCustomComponentDefinitionDetails(val)) |
197 | 197 | } else if (val.constructor && val.constructor.name === 'VNode') { |
198 | 198 | return `[native VNode <${val.tag}>]` |
| 199 | + } else if (val instanceof HTMLElement) { |
| 200 | + return encodeCache.cache(val, () => getCustomHTMLElementDetails(val)) |
199 | 201 | } |
200 | 202 | } else if (Number.isNaN(val)) { |
201 | 203 | return NAN |
@@ -322,6 +324,26 @@ export function getCustomFunctionDetails (func) { |
322 | 324 | } |
323 | 325 | } |
324 | 326 |
|
| 327 | +export function getCustomHTMLElementDetails (value: HTMLElement): CustomState { |
| 328 | + return { |
| 329 | + _custom: { |
| 330 | + type: 'HTMLElement', |
| 331 | + display: `<span class="opacity-30"><</span><span class="text-blue-500">${value.tagName.toLowerCase()}</span><span class="opacity-30">></span>`, |
| 332 | + value: namedNodeMapToObject(value.attributes) |
| 333 | + } |
| 334 | + } |
| 335 | +} |
| 336 | + |
| 337 | +function namedNodeMapToObject (map: NamedNodeMap) { |
| 338 | + const result: any = {} |
| 339 | + const l = map.length |
| 340 | + for (let i = 0; i < l; i++) { |
| 341 | + const node = map.item(i) |
| 342 | + result[node.name] = node.value |
| 343 | + } |
| 344 | + return result |
| 345 | +} |
| 346 | + |
325 | 347 | export function getCustomRefDetails (instance, key, ref) { |
326 | 348 | let value |
327 | 349 | if (Array.isArray(ref)) { |
|
0 commit comments