(view: ViewBase, domId: number)
| 164 | * Returns an instance of a view (if found), otherwise undefined. |
| 165 | */ |
| 166 | export function getViewByDomId(view: ViewBase, domId: number): ViewBase { |
| 167 | if (!view) { |
| 168 | return undefined; |
| 169 | } |
| 170 | |
| 171 | if (view._domId === domId) { |
| 172 | return view; |
| 173 | } |
| 174 | |
| 175 | let retVal: ViewBase; |
| 176 | const descendantsCallback = function (child: ViewBase): boolean { |
| 177 | if (view._domId === domId) { |
| 178 | retVal = child; |
| 179 | |
| 180 | // break the iteration by returning false |
| 181 | return false; |
| 182 | } |
| 183 | |
| 184 | return true; |
| 185 | }; |
| 186 | |
| 187 | eachDescendant(view, descendantsCallback); |
| 188 | |
| 189 | return retVal; |
| 190 | } |
| 191 | |
| 192 | // TODO: allow all selector types (just using attributes now) |
| 193 | /** |
nothing calls this directly
no test coverage detected