( root: HTMLElement | undefined, chain: RouteChain, direction: RouterDirection, index: number, changed = false, animation?: AnimationBuilder )
| 16 | * setRouteId will create or select the view in the outlet. |
| 17 | */ |
| 18 | export const writeNavState = async ( |
| 19 | root: HTMLElement | undefined, |
| 20 | chain: RouteChain, |
| 21 | direction: RouterDirection, |
| 22 | index: number, |
| 23 | changed = false, |
| 24 | animation?: AnimationBuilder |
| 25 | ): Promise<boolean> => { |
| 26 | try { |
| 27 | // find next navigation outlet in the DOM |
| 28 | const outlet = searchNavNode(root); |
| 29 | |
| 30 | // make sure we can continue interacting the DOM, otherwise abort |
| 31 | if (index >= chain.length || !outlet) { |
| 32 | return changed; |
| 33 | } |
| 34 | await new Promise((resolve) => componentOnReady(outlet, resolve)); |
| 35 | |
| 36 | const route = chain[index]; |
| 37 | const result = await outlet.setRouteId(route.id, route.params, direction, animation); |
| 38 | |
| 39 | // if the outlet changed the page, reset navigation to neutral (no direction) |
| 40 | // this means nested outlets will not animate |
| 41 | if (result.changed) { |
| 42 | direction = ROUTER_INTENT_NONE; |
| 43 | changed = true; |
| 44 | } |
| 45 | |
| 46 | // recursively set nested outlets |
| 47 | changed = await writeNavState(result.element, chain, direction, index + 1, changed, animation); |
| 48 | |
| 49 | // once all nested outlets are visible let's make the parent visible too, |
| 50 | // using markVisible prevents flickering |
| 51 | if (result.markVisible) { |
| 52 | await result.markVisible(); |
| 53 | } |
| 54 | return changed; |
| 55 | } catch (e) { |
| 56 | printIonError('[ion-router] - Exception in writeNavState:', e); |
| 57 | return false; |
| 58 | } |
| 59 | }; |
| 60 | |
| 61 | /** |
| 62 | * Recursively walks the outlet in the DOM. |
no test coverage detected