(direction: RouterDirection)
| 185 | /** @internal */ |
| 186 | @Method() |
| 187 | async navChanged(direction: RouterDirection): Promise<boolean> { |
| 188 | if (this.busy) { |
| 189 | printIonWarning('[ion-router] - Router is busy, navChanged was cancelled.'); |
| 190 | return false; |
| 191 | } |
| 192 | const { ids, outlet } = await readNavState(window.document.body); |
| 193 | const routes = readRoutes(this.el); |
| 194 | const chain = findChainForIDs(ids, routes); |
| 195 | if (!chain) { |
| 196 | printIonWarning( |
| 197 | '[ion-router] - No matching URL for', |
| 198 | ids.map((i) => i.id) |
| 199 | ); |
| 200 | return false; |
| 201 | } |
| 202 | |
| 203 | const segments = chainToSegments(chain); |
| 204 | if (!segments) { |
| 205 | printIonWarning('[ion-router] - Router could not match path because some required param is missing.'); |
| 206 | return false; |
| 207 | } |
| 208 | |
| 209 | // navChanged is an outlet-driven URL sync. Only keep the fragment when |
| 210 | // the path is unchanged; on a real navigation it refers to an anchor on |
| 211 | // the page being left and would be stale. |
| 212 | const newPath = generatePath(segments); |
| 213 | const fragment = newPath === this.previousPath ? this.getFragment() : undefined; |
| 214 | this.setSegments(segments, direction, undefined, fragment); |
| 215 | |
| 216 | await this.safeWriteNavState(outlet, chain, ROUTER_INTENT_NONE, segments, null, ids.length); |
| 217 | return true; |
| 218 | } |
| 219 | |
| 220 | /** This handler gets called when a `ion-route-redirect` component is added to the DOM or if the from or to property of such node changes. */ |
| 221 | private onRedirectChanged() { |
no test coverage detected