MCPcopy Index your code
hub / github.com/ionic-team/ionic-framework / writeNavStateRoot

Method writeNavStateRoot

core/src/components/router/router.tsx:254–287  ·  view source on GitHub ↗
(
    segments: string[] | null,
    direction: RouterDirection,
    animation?: AnimationBuilder
  )

Source from the content-addressed store, hash-verified

252 }
253
254 private async writeNavStateRoot(
255 segments: string[] | null,
256 direction: RouterDirection,
257 animation?: AnimationBuilder
258 ): Promise<boolean> {
259 if (!segments) {
260 printIonError('[ion-router] - URL is not part of the routing set.');
261 return false;
262 }
263
264 // lookup redirect rule
265 const redirects = readRedirects(this.el);
266 const redirect = findRouteRedirect(segments, redirects);
267
268 let redirectFrom: string[] | null = null;
269
270 if (redirect) {
271 const { segments: toSegments, queryString, fragment } = redirect.to!;
272 this.setSegments(toSegments, direction, queryString, fragment);
273 redirectFrom = redirect.from;
274 segments = toSegments;
275 }
276
277 // lookup route chain
278 const routes = readRoutes(this.el);
279 const chain = findChainForSegments(segments, routes);
280 if (!chain) {
281 printIonError('[ion-router] - The path does not match any route.');
282 return false;
283 }
284
285 // write DOM give
286 return this.safeWriteNavState(document.body, chain, direction, segments, redirectFrom, 0, animation);
287 }
288
289 private async safeWriteNavState(
290 node: HTMLElement | undefined,

Callers 5

componentWillLoadMethod · 0.95
onPopStateMethod · 0.95
pushMethod · 0.95
onRedirectChangedMethod · 0.95
onRoutesChangedMethod · 0.95

Calls 7

setSegmentsMethod · 0.95
safeWriteNavStateMethod · 0.95
printIonErrorFunction · 0.90
readRedirectsFunction · 0.90
findRouteRedirectFunction · 0.90
readRoutesFunction · 0.90
findChainForSegmentsFunction · 0.90

Tested by

no test coverage detected