(
r: ComponentRegistry<TEl>,
el: TEl,
)
| 177 | |
| 178 | export |
| 179 | const findComponent = <TEl extends object>( |
| 180 | r: ComponentRegistry<TEl>, |
| 181 | el: TEl, |
| 182 | ): ComponentData<TEl> | null => { |
| 183 | |
| 184 | let including = new Map<Solid.Owner, ComponentData<TEl>>() |
| 185 | |
| 186 | for (let curr: TEl | null = el; |
| 187 | curr != null && including.size === 0; |
| 188 | ) { |
| 189 | for (let comp of r.components.values()) { |
| 190 | for (let comp_el of comp.elements) { |
| 191 | if (comp_el === curr) { |
| 192 | including.set(comp.owner, comp) |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | curr = r.eli.getParent(curr) // go up |
| 197 | } |
| 198 | |
| 199 | if (including.size > 1) { |
| 200 | // find the closest component |
| 201 | for (let owner of including.keys()) { |
| 202 | if (including.has(owner)) { |
| 203 | for (let curr = owner.owner; curr != null;) { |
| 204 | if (including.delete(curr)) break |
| 205 | curr = curr.owner // go up |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | return including.values().next().value ?? null |
| 212 | } |
| 213 | |
| 214 | |
| 215 | export |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…