(
r: ComponentRegistry<TEl>,
id: NodeID,
)
| 132 | |
| 133 | export |
| 134 | const getComponent = <TEl extends object>( |
| 135 | r: ComponentRegistry<TEl>, |
| 136 | id: NodeID, |
| 137 | ): {name: string | undefined; id: NodeID; elements: TEl[]} | null => { |
| 138 | // provided if might be of an element node (in DOM mode) or component node |
| 139 | // both need to be checked |
| 140 | |
| 141 | let component = r.components.get(id) |
| 142 | if (component != null) return { |
| 143 | name: component.name, |
| 144 | elements: [...component.elements], |
| 145 | id: id, |
| 146 | } |
| 147 | |
| 148 | let el_data = r.element_nodes.get(id) |
| 149 | if (el_data == null) return null |
| 150 | |
| 151 | return { |
| 152 | name: el_data.component.name, |
| 153 | id: el_data.component.id, |
| 154 | elements: [el_data.el], |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Searches for an HTML element with the given id in the component with the given id. |
nothing calls this directly
no test coverage detected
searching dependent graphs…