|
37 | 37 | y = event.y; |
38 | 38 | } |
39 | 39 |
|
40 | | - function findMetaEl(el) { |
| 40 | + function find_parent_with_meta(el) { |
41 | 41 | while (el) { |
42 | | - const file = el.__svelte_meta?.loc?.file; |
43 | | - if (el !== toggle_el && file && !file.includes('node_modules/')) { |
| 42 | + if (has_meta(el)) { |
44 | 43 | return el; |
45 | 44 | } |
46 | 45 | el = el.parentNode; |
47 | 46 | } |
48 | 47 | } |
49 | 48 |
|
| 49 | + function find_child_with_meta(el) { |
| 50 | + return [...el.querySelectorAll('*')].find(has_meta); |
| 51 | + } |
| 52 | +
|
| 53 | + function has_meta(el) { |
| 54 | + const file = el.__svelte_meta?.loc?.file; |
| 55 | + return el !== toggle_el && file && !file.includes('node_modules/'); |
| 56 | + } |
| 57 | +
|
50 | 58 | function mouseover(event) { |
51 | | - const el = findMetaEl(event.target); |
| 59 | + const el = find_parent_with_meta(event.target); |
| 60 | + activate(el); |
| 61 | + } |
| 62 | +
|
| 63 | + function activate(el) { |
52 | 64 | if (options.customStyles && el !== active_el) { |
53 | 65 | if (active_el) { |
54 | 66 | active_el.classList.remove('svelte-inspector-active-target'); |
|
68 | 80 |
|
69 | 81 | function click(event) { |
70 | 82 | if (file_loc) { |
71 | | - event.preventDefault(); |
72 | | - event.stopPropagation(); |
73 | | - event.stopImmediatePropagation(); |
| 83 | + stop(event); |
74 | 84 | fetch(`/__open-in-editor?file=${encodeURIComponent(file_loc)}`); |
75 | 85 | if (options.holdMode && is_holding()) { |
76 | 86 | disable(); |
|
98 | 108 | return enabled_ts && Date.now() - enabled_ts > 250; |
99 | 109 | } |
100 | 110 |
|
| 111 | + function stop(event) { |
| 112 | + event.preventDefault(); |
| 113 | + event.stopPropagation(); |
| 114 | + event.stopImmediatePropagation(); |
| 115 | + } |
| 116 | +
|
101 | 117 | function keydown(event) { |
102 | 118 | if (event.repeat || event.key == null) { |
103 | 119 | return; |
|
108 | 124 | if (options.holdMode && enabled) { |
109 | 125 | enabled_ts = Date.now(); |
110 | 126 | } |
| 127 | + } else if (event.key === options.drillKeys.up && active_el) { |
| 128 | + const el = find_parent_with_meta(active_el.parentNode); |
| 129 | + if (el) { |
| 130 | + activate(el); |
| 131 | + stop(event); |
| 132 | + } |
| 133 | + } else if (event.key === options.drillKeys.down && active_el) { |
| 134 | + const el = find_child_with_meta(active_el); |
| 135 | + if (el) { |
| 136 | + activate(el); |
| 137 | + stop(event); |
| 138 | + } |
111 | 139 | } |
112 | 140 | } |
113 | 141 |
|
|
203 | 231 | style:top="{y + 30}px" |
204 | 232 | bind:offsetWidth={w} |
205 | 233 | > |
206 | | - {file_loc} |
| 234 | + <{active_el.tagName.toLowerCase()}> {file_loc} |
207 | 235 | </div> |
208 | 236 | {/if} |
209 | 237 |
|
|
0 commit comments