( instance: ComponentInternalInstance, fn: (instance: ComponentInternalInstance) => any, onError?: (err: Error) => void )
| 188 | } |
| 189 | |
| 190 | export function activateCurrentInstance( |
| 191 | instance: ComponentInternalInstance, |
| 192 | fn: (instance: ComponentInternalInstance) => any, |
| 193 | onError?: (err: Error) => void |
| 194 | ) { |
| 195 | let preVm = getCurrentInstance() |
| 196 | setCurrentInstance(instance) |
| 197 | try { |
| 198 | return fn(instance) |
| 199 | } catch ( |
| 200 | // FIXME: remove any |
| 201 | err: any |
| 202 | ) { |
| 203 | if (onError) { |
| 204 | onError(err) |
| 205 | } else { |
| 206 | throw err |
| 207 | } |
| 208 | } finally { |
| 209 | setCurrentInstance(preVm) |
| 210 | } |
| 211 | } |
no test coverage detected
searching dependent graphs…