@angular/router
Advanced tools
Comparing version 3.2.0-rc.0 to 3.2.0
/** | ||
* @license Angular v3.2.0-rc.0 | ||
* @license Angular v3.2.0 | ||
* (c) 2010-2016 Google, Inc. https://angular.io/ | ||
@@ -4,0 +4,0 @@ * License: MIT |
{ | ||
"name": "@angular/router", | ||
"version": "3.2.0-rc.0", | ||
"version": "3.2.0", | ||
"description": "Angular - the routing library", | ||
@@ -24,7 +24,8 @@ "main": "bundles/router.umd.js", | ||
"peerDependencies": { | ||
"@angular/core": "2.2.0-rc.0", | ||
"@angular/common": "2.2.0-rc.0", | ||
"@angular/platform-browser": "2.2.0-rc.0", | ||
"@angular/core": "2.2.0", | ||
"@angular/common": "2.2.0", | ||
"@angular/platform-browser": "2.2.0", | ||
"@angular/upgrade": "2.2.0", | ||
"rxjs": "5.0.0-beta.12" | ||
} | ||
} |
@@ -18,3 +18,3 @@ /** | ||
import { LoadedRouterConfig } from './router_config_loader'; | ||
import { NavigationCancelingError, PRIMARY_OUTLET } from './shared'; | ||
import { NavigationCancelingError, PRIMARY_OUTLET, defaultUrlMatcher } from './shared'; | ||
import { UrlSegment, UrlSegmentGroup, UrlTree } from './url_tree'; | ||
@@ -127,3 +127,8 @@ import { andObservables, merge, waitForMap, wrapIntoObservable } from './utils/collection'; | ||
if (e instanceof EmptyError) { | ||
throw new NoMatch(segmentGroup); | ||
if (_this.noLeftoversInUrl(segmentGroup, segments, outlet)) { | ||
return of(new UrlSegmentGroup([], {})); | ||
} | ||
else { | ||
throw new NoMatch(segmentGroup); | ||
} | ||
} | ||
@@ -135,2 +140,5 @@ else { | ||
}; | ||
ApplyRedirects.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) { | ||
return segments.length === 0 && !segmentGroup.children[outlet]; | ||
}; | ||
ApplyRedirects.prototype.expandSegmentAgainstRoute = function (injector, segmentGroup, routes, route, paths, outlet, allowRedirects) { | ||
@@ -218,3 +226,3 @@ if (getOutlet(route) !== outlet) | ||
if (route.children) { | ||
return of(new LoadedRouterConfig(route.children, injector, null)); | ||
return of(new LoadedRouterConfig(route.children, injector, null, null)); | ||
} | ||
@@ -240,3 +248,3 @@ else if (route.loadChildren) { | ||
else { | ||
return of(new LoadedRouterConfig([], injector, null)); | ||
return of(new LoadedRouterConfig([], injector, null, null)); | ||
} | ||
@@ -271,26 +279,12 @@ }; | ||
} | ||
var path = route.path; | ||
var parts = path.split('/'); | ||
var positionalParamSegments = {}; | ||
var consumedSegments = []; | ||
var currentIndex = 0; | ||
for (var i = 0; i < parts.length; ++i) { | ||
if (currentIndex >= segments.length) | ||
return noMatch; | ||
var current = segments[currentIndex]; | ||
var p = parts[i]; | ||
var isPosParam = p.startsWith(':'); | ||
if (!isPosParam && p !== current.path) | ||
return noMatch; | ||
if (isPosParam) { | ||
positionalParamSegments[p.substring(1)] = current; | ||
} | ||
consumedSegments.push(current); | ||
currentIndex++; | ||
} | ||
if (route.pathMatch === 'full' && | ||
(segmentGroup.hasChildren() || currentIndex < segments.length)) { | ||
return { matched: false, consumedSegments: [], lastChild: 0, positionalParamSegments: {} }; | ||
} | ||
return { matched: true, consumedSegments: consumedSegments, lastChild: currentIndex, positionalParamSegments: positionalParamSegments }; | ||
var matcher = route.matcher || defaultUrlMatcher; | ||
var res = matcher(segments, segmentGroup, route); | ||
if (!res) | ||
return noMatch; | ||
return { | ||
matched: true, | ||
consumedSegments: res.consumed, | ||
lastChild: res.consumed.length, | ||
positionalParamSegments: res.posParams | ||
}; | ||
} | ||
@@ -297,0 +291,0 @@ function applyRedirectCommands(segments, redirectTo, posParams) { |
@@ -10,2 +10,3 @@ /** | ||
import { Observable } from 'rxjs/Observable'; | ||
import { UrlSegment, UrlSegmentGroup } from './url_tree'; | ||
/** | ||
@@ -260,2 +261,37 @@ * @whatItDoes Represents router configuration. | ||
/** | ||
* @whatItDoes Represents the results of the URL matching. | ||
* | ||
* * `consumed` is an array of the consumed URL segments. | ||
* * `posParams` is a map of positional parameters. | ||
* | ||
* @experimental | ||
*/ | ||
export declare type UrlMatchResult = { | ||
consumed: UrlSegment[]; | ||
posParams?: { | ||
[name: string]: UrlSegment; | ||
}; | ||
}; | ||
/** | ||
* @whatItDoes A function matching URLs | ||
* | ||
* @description | ||
* | ||
* A custom URL matcher can be provided when a combination of `path` and `pathMatch` isn't | ||
* expressive enough. | ||
* | ||
* For instance, the following matcher matches html files. | ||
* | ||
* ``` | ||
* function htmlFiles(url: UrlSegment[]) { | ||
* return url.length === 1 && url[0].path.endsWith('.html') ? ({consumed: url}) : null; | ||
* } | ||
* | ||
* const routes = [{ matcher: htmlFiles, component: HtmlCmp }]; | ||
* ``` | ||
* | ||
* @experimental | ||
*/ | ||
export declare type UrlMatcher = (segments: UrlSegment[], group: UrlSegmentGroup, route: Route) => UrlMatchResult; | ||
/** | ||
* @whatItDoes Represents the static data associated with a particular route. | ||
@@ -269,3 +305,3 @@ * See {@link Routes} for more details. | ||
/** | ||
* @whatItDoes Represents the resolved data associated with a particular route. | ||
* @whatItDoes Represents the resolved data associated with a particular route. | ||
* See {@link Routes} for more details. | ||
@@ -297,2 +333,3 @@ * @stable | ||
pathMatch?: string; | ||
matcher?: UrlMatcher; | ||
component?: Type<any>; | ||
@@ -299,0 +336,0 @@ redirectTo?: string; |
@@ -10,5 +10,11 @@ /** | ||
export function validateConfig(config) { | ||
config.forEach(validateNode); | ||
// forEach doesn't iterate undefined values | ||
for (var i = 0; i < config.length; i++) { | ||
validateNode(config[i]); | ||
} | ||
} | ||
function validateNode(route) { | ||
if (!route) { | ||
throw new Error("\n Invalid route configuration: Encountered undefined route.\n The reason might be an extra comma.\n \n Example: \n const routes: Routes = [\n { path: '', redirectTo: '/dashboard', pathMatch: 'full' },\n { path: 'dashboard', component: DashboardComponent },, << two commas\n { path: 'detail/:id', component: HeroDetailComponent }\n ];\n "); | ||
} | ||
if (Array.isArray(route)) { | ||
@@ -32,2 +38,5 @@ throw new Error("Invalid route configuration: Array cannot be specified"); | ||
} | ||
if (!!route.path && !!route.matcher) { | ||
throw new Error("Invalid configuration of route '" + route.path + "': path and matcher cannot be used together"); | ||
} | ||
if (route.redirectTo === undefined && !route.component && !route.children && | ||
@@ -34,0 +43,0 @@ !route.loadChildren) { |
@@ -48,2 +48,4 @@ /** | ||
ngOnDestroy(): void; | ||
locationInjector: Injector; | ||
locationFactoryResolver: ComponentFactoryResolver; | ||
isActivated: boolean; | ||
@@ -53,3 +55,3 @@ component: Object; | ||
deactivate(): void; | ||
activate(activatedRoute: ActivatedRoute, loadedResolver: ComponentFactoryResolver, loadedInjector: Injector, providers: ResolvedReflectiveProvider[], outletMap: RouterOutletMap): void; | ||
activate(activatedRoute: ActivatedRoute, resolver: ComponentFactoryResolver, injector: Injector, providers: ResolvedReflectiveProvider[], outletMap: RouterOutletMap): void; | ||
} |
@@ -47,2 +47,12 @@ /** | ||
RouterOutlet.prototype.ngOnDestroy = function () { this.parentOutletMap.removeOutlet(this.name ? this.name : PRIMARY_OUTLET); }; | ||
Object.defineProperty(RouterOutlet.prototype, "locationInjector", { | ||
get: function () { return this.location.injector; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RouterOutlet.prototype, "locationFactoryResolver", { | ||
get: function () { return this.resolver; }, | ||
enumerable: true, | ||
configurable: true | ||
}); | ||
Object.defineProperty(RouterOutlet.prototype, "isActivated", { | ||
@@ -79,3 +89,3 @@ get: function () { return !!this.activated; }, | ||
}; | ||
RouterOutlet.prototype.activate = function (activatedRoute, loadedResolver, loadedInjector, providers, outletMap) { | ||
RouterOutlet.prototype.activate = function (activatedRoute, resolver, injector, providers, outletMap) { | ||
if (this.isActivated) { | ||
@@ -88,10 +98,3 @@ throw new Error('Cannot activate an already activated outlet'); | ||
var component = snapshot._routeConfig.component; | ||
var factory; | ||
if (loadedResolver) { | ||
factory = loadedResolver.resolveComponentFactory(component); | ||
} | ||
else { | ||
factory = this.resolver.resolveComponentFactory(component); | ||
} | ||
var injector = loadedInjector ? loadedInjector : this.location.parentInjector; | ||
var factory = resolver.resolveComponentFactory(component); | ||
var inj = ReflectiveInjector.fromResolvedProviders(providers, injector); | ||
@@ -98,0 +101,0 @@ this.activated = this.location.createComponent(factory, this.location.length, inj, []); |
@@ -14,5 +14,5 @@ /** | ||
export { Event, NavigationCancel, NavigationEnd, NavigationError, NavigationExtras, NavigationStart, Router, RoutesRecognized } from './router'; | ||
export { ExtraOptions, RouterModule, provideRoutes } from './router_module'; | ||
export { ExtraOptions, ROUTER_CONFIGURATION, ROUTER_INITIALIZER, RouterModule, provideRoutes } from './router_module'; | ||
export { RouterOutletMap } from './router_outlet_map'; | ||
export { NoPreloading, PreloadAllModules, PreloadingStrategy } from './router_preloader'; | ||
export { NoPreloading, PreloadAllModules, PreloadingStrategy, RouterPreloader } from './router_preloader'; | ||
export { ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot } from './router_state'; | ||
@@ -19,0 +19,0 @@ export { PRIMARY_OUTLET, Params } from './shared'; |
@@ -12,5 +12,5 @@ /** | ||
export { NavigationCancel, NavigationEnd, NavigationError, NavigationStart, Router, RoutesRecognized } from './router'; | ||
export { RouterModule, provideRoutes } from './router_module'; | ||
export { ROUTER_CONFIGURATION, ROUTER_INITIALIZER, RouterModule, provideRoutes } from './router_module'; | ||
export { RouterOutletMap } from './router_outlet_map'; | ||
export { NoPreloading, PreloadAllModules, PreloadingStrategy } from './router_preloader'; | ||
export { NoPreloading, PreloadAllModules, PreloadingStrategy, RouterPreloader } from './router_preloader'; | ||
export { ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot } from './router_state'; | ||
@@ -17,0 +17,0 @@ export { PRIMARY_OUTLET } from './shared'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./config","export":["Data","LoadChildren","LoadChildrenCallback","ResolveData","Route","Routes"]},{"from":"./directives/router_link","export":["RouterLink","RouterLinkWithHref"]},{"from":"./directives/router_link_active","export":["RouterLinkActive"]},{"from":"./directives/router_outlet","export":["RouterOutlet"]},{"from":"./interfaces","export":["CanActivate","CanActivateChild","CanDeactivate","CanLoad","Resolve"]},{"from":"./router","export":["Event","NavigationCancel","NavigationEnd","NavigationError","NavigationExtras","NavigationStart","Router","RoutesRecognized"]},{"from":"./router_module","export":["ExtraOptions","RouterModule","provideRoutes"]},{"from":"./router_outlet_map","export":["RouterOutletMap"]},{"from":"./router_preloader","export":["NoPreloading","PreloadAllModules","PreloadingStrategy"]},{"from":"./router_state","export":["ActivatedRoute","ActivatedRouteSnapshot","RouterState","RouterStateSnapshot"]},{"from":"./shared","export":["PRIMARY_OUTLET","Params"]},{"from":"./url_handling_strategy","export":["UrlHandlingStrategy"]},{"from":"./url_tree","export":["DefaultUrlSerializer","UrlSegment","UrlSegmentGroup","UrlSerializer","UrlTree"]},{"from":"./private_export"}]} | ||
{"__symbolic":"module","version":1,"metadata":{},"exports":[{"from":"./config","export":["Data","LoadChildren","LoadChildrenCallback","ResolveData","Route","Routes"]},{"from":"./directives/router_link","export":["RouterLink","RouterLinkWithHref"]},{"from":"./directives/router_link_active","export":["RouterLinkActive"]},{"from":"./directives/router_outlet","export":["RouterOutlet"]},{"from":"./interfaces","export":["CanActivate","CanActivateChild","CanDeactivate","CanLoad","Resolve"]},{"from":"./router","export":["Event","NavigationCancel","NavigationEnd","NavigationError","NavigationExtras","NavigationStart","Router","RoutesRecognized"]},{"from":"./router_module","export":["ExtraOptions","ROUTER_CONFIGURATION","ROUTER_INITIALIZER","RouterModule","provideRoutes"]},{"from":"./router_outlet_map","export":["RouterOutletMap"]},{"from":"./router_preloader","export":["NoPreloading","PreloadAllModules","PreloadingStrategy","RouterPreloader"]},{"from":"./router_state","export":["ActivatedRoute","ActivatedRouteSnapshot","RouterState","RouterStateSnapshot"]},{"from":"./shared","export":["PRIMARY_OUTLET","Params"]},{"from":"./url_handling_strategy","export":["UrlHandlingStrategy"]},{"from":"./url_tree","export":["DefaultUrlSerializer","UrlSegment","UrlSegmentGroup","UrlSerializer","UrlTree"]},{"from":"./private_export"}]} |
@@ -11,5 +11,5 @@ /** | ||
import { ActivatedRouteSnapshot, RouterStateSnapshot, inheritedParamsDataResolve } from './router_state'; | ||
import { PRIMARY_OUTLET } from './shared'; | ||
import { PRIMARY_OUTLET, defaultUrlMatcher } from './shared'; | ||
import { UrlSegmentGroup, mapChildrenIntoArray } from './url_tree'; | ||
import { last, merge } from './utils/collection'; | ||
import { forEach, last, merge } from './utils/collection'; | ||
import { TreeNode } from './utils/tree'; | ||
@@ -79,4 +79,12 @@ var NoMatch = (function () { | ||
} | ||
throw new NoMatch(); | ||
if (this.noLeftoversInUrl(segmentGroup, segments, outlet)) { | ||
return []; | ||
} | ||
else { | ||
throw new NoMatch(); | ||
} | ||
}; | ||
Recognizer.prototype.noLeftoversInUrl = function (segmentGroup, segments, outlet) { | ||
return segments.length === 0 && !segmentGroup.children[outlet]; | ||
}; | ||
Recognizer.prototype.processSegmentAgainstRoute = function (route, rawSegment, pathIndex, segments, outlet) { | ||
@@ -140,27 +148,10 @@ if (route.redirectTo) | ||
} | ||
var path = route.path; | ||
var parts = path.split('/'); | ||
var posParameters = {}; | ||
var consumedSegments = []; | ||
var currentIndex = 0; | ||
for (var i = 0; i < parts.length; ++i) { | ||
if (currentIndex >= segments.length) | ||
throw new NoMatch(); | ||
var current = segments[currentIndex]; | ||
var p = parts[i]; | ||
var isPosParam = p.startsWith(':'); | ||
if (!isPosParam && p !== current.path) | ||
throw new NoMatch(); | ||
if (isPosParam) { | ||
posParameters[p.substring(1)] = current.path; | ||
} | ||
consumedSegments.push(current); | ||
currentIndex++; | ||
} | ||
if (route.pathMatch === 'full' && | ||
(segmentGroup.hasChildren() || currentIndex < segments.length)) { | ||
var matcher = route.matcher || defaultUrlMatcher; | ||
var res = matcher(segments, segmentGroup, route); | ||
if (!res) | ||
throw new NoMatch(); | ||
} | ||
var parameters = merge(posParameters, consumedSegments[consumedSegments.length - 1].parameters); | ||
return { consumedSegments: consumedSegments, lastChild: currentIndex, parameters: parameters }; | ||
var posParams = {}; | ||
forEach(res.posParams, function (v, k) { posParams[k] = v.path; }); | ||
var parameters = merge(posParams, res.consumed[res.consumed.length - 1].parameters); | ||
return { consumedSegments: res.consumed, lastChild: res.consumed.length, parameters: parameters }; | ||
} | ||
@@ -167,0 +158,0 @@ function checkOutletNameUniqueness(nodes) { |
@@ -19,3 +19,4 @@ /** | ||
factoryResolver: ComponentFactoryResolver; | ||
constructor(routes: Route[], injector: Injector, factoryResolver: ComponentFactoryResolver); | ||
injectorFactory: Function; | ||
constructor(routes: Route[], injector: Injector, factoryResolver: ComponentFactoryResolver, injectorFactory: Function); | ||
} | ||
@@ -22,0 +23,0 @@ export declare class RouterConfigLoader { |
@@ -19,6 +19,7 @@ /** | ||
export var LoadedRouterConfig = (function () { | ||
function LoadedRouterConfig(routes, injector, factoryResolver) { | ||
function LoadedRouterConfig(routes, injector, factoryResolver, injectorFactory) { | ||
this.routes = routes; | ||
this.injector = injector; | ||
this.factoryResolver = factoryResolver; | ||
this.injectorFactory = injectorFactory; | ||
} | ||
@@ -35,3 +36,4 @@ return LoadedRouterConfig; | ||
var ref = r.create(parentInjector); | ||
return new LoadedRouterConfig(flatten(ref.injector.get(ROUTES)), ref.injector, ref.componentFactoryResolver); | ||
var injectorFactory = function (parent) { return r.create(parent).injector; }; | ||
return new LoadedRouterConfig(flatten(ref.injector.get(ROUTES)), ref.injector, ref.componentFactoryResolver, injectorFactory); | ||
}); | ||
@@ -38,0 +40,0 @@ }; |
@@ -9,3 +9,3 @@ /** | ||
import { HashLocationStrategy, Location, PathLocationStrategy, PlatformLocation } from '@angular/common'; | ||
import { ApplicationRef, Compiler, Injector, ModuleWithProviders, NgModuleFactoryLoader, OpaqueToken, Provider } from '@angular/core'; | ||
import { ApplicationRef, Compiler, ComponentRef, Injector, ModuleWithProviders, NgModuleFactoryLoader, OpaqueToken, Provider } from '@angular/core'; | ||
import { Route, Routes } from './config'; | ||
@@ -146,8 +146,17 @@ import { ErrorHandler, Router } from './router'; | ||
export declare function rootRoute(router: Router): ActivatedRoute; | ||
export declare function initialRouterNavigation(router: Router, ref: ApplicationRef, preloader: RouterPreloader, opts: ExtraOptions): () => void; | ||
export declare function provideRouterInitializer(): { | ||
export declare function initialRouterNavigation(router: Router, ref: ApplicationRef, preloader: RouterPreloader, opts: ExtraOptions): (bootstrappedComponentRef: ComponentRef<any>) => void; | ||
/** | ||
* A token for the router initializer that will be called after the app is bootstrapped. | ||
* | ||
* @experimental | ||
*/ | ||
export declare const ROUTER_INITIALIZER: OpaqueToken; | ||
export declare function provideRouterInitializer(): ({ | ||
provide: OpaqueToken; | ||
useFactory: (router: Router, ref: ApplicationRef, preloader: RouterPreloader, opts: ExtraOptions) => (bootstrappedComponentRef: ComponentRef<any>) => void; | ||
deps: (OpaqueToken | typeof Router | typeof RouterPreloader | typeof ApplicationRef)[]; | ||
} | { | ||
provide: OpaqueToken; | ||
multi: boolean; | ||
useFactory: (router: Router, ref: ApplicationRef, preloader: RouterPreloader, opts: ExtraOptions) => () => void; | ||
deps: (OpaqueToken | typeof Router | typeof RouterPreloader | typeof ApplicationRef)[]; | ||
}; | ||
useExisting: OpaqueToken; | ||
})[]; |
@@ -13,2 +13,3 @@ /** | ||
import { RouterOutlet } from './directives/router_outlet'; | ||
import { getDOM } from './private_import_platform-browser'; | ||
import { Router } from './router'; | ||
@@ -205,7 +206,8 @@ import { ROUTES } from './router_config_loader'; | ||
if (opts.enableTracing) { | ||
var dom_1 = getDOM(); | ||
router.events.subscribe(function (e) { | ||
console.group("Router Event: " + e.constructor.name); | ||
console.log(e.toString()); | ||
console.log(e); | ||
console.groupEnd(); | ||
dom_1.logGroup("Router Event: " + e.constructor.name); | ||
dom_1.log(e.toString()); | ||
dom_1.log(e); | ||
dom_1.logGroupEnd(); | ||
}); | ||
@@ -219,3 +221,6 @@ } | ||
export function initialRouterNavigation(router, ref, preloader, opts) { | ||
return function () { | ||
return function (bootstrappedComponentRef) { | ||
if (bootstrappedComponentRef !== ref.components[0]) { | ||
return; | ||
} | ||
router.resetRootComponentType(ref.componentTypes[0]); | ||
@@ -231,10 +236,18 @@ preloader.setUpPreloading(); | ||
} | ||
/** | ||
* A token for the router initializer that will be called after the app is bootstrapped. | ||
* | ||
* @experimental | ||
*/ | ||
export var ROUTER_INITIALIZER = new OpaqueToken('Router Initializer'); | ||
export function provideRouterInitializer() { | ||
return { | ||
provide: APP_BOOTSTRAP_LISTENER, | ||
multi: true, | ||
useFactory: initialRouterNavigation, | ||
deps: [Router, ApplicationRef, RouterPreloader, ROUTER_CONFIGURATION] | ||
}; | ||
return [ | ||
{ | ||
provide: ROUTER_INITIALIZER, | ||
useFactory: initialRouterNavigation, | ||
deps: [Router, ApplicationRef, RouterPreloader, ROUTER_CONFIGURATION] | ||
}, | ||
{ provide: APP_BOOTSTRAP_LISTENER, multi: true, useExisting: ROUTER_INITIALIZER } | ||
]; | ||
} | ||
//# sourceMappingURL=router_module.js.map |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"ROUTER_CONFIGURATION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["ROUTER_CONFIGURATION"]},"ROUTER_FORROOT_GUARD":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["ROUTER_FORROOT_GUARD"]},"ROUTER_PROVIDERS":[{"__symbolic":"reference","module":"@angular/common","name":"Location"},{"provide":{"__symbolic":"reference","module":"./url_tree","name":"UrlSerializer"},"useClass":{"__symbolic":"reference","module":"./url_tree","name":"DefaultUrlSerializer"}},{"provide":{"__symbolic":"reference","module":"./router","name":"Router"},"useFactory":{"__symbolic":"reference","name":"setupRouter"},"deps":[{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef"},{"__symbolic":"reference","module":"./url_tree","name":"UrlSerializer"},{"__symbolic":"reference","module":"./router_outlet_map","name":"RouterOutletMap"},{"__symbolic":"reference","module":"@angular/common","name":"Location"},{"__symbolic":"reference","module":"@angular/core","name":"Injector"},{"__symbolic":"reference","module":"@angular/core","name":"NgModuleFactoryLoader"},{"__symbolic":"reference","module":"@angular/core","name":"Compiler"},{"__symbolic":"reference","module":"./router_config_loader","name":"ROUTES"},{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},[{"__symbolic":"reference","module":"./url_handling_strategy","name":"UrlHandlingStrategy"},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}}]]},{"__symbolic":"reference","module":"./router_outlet_map","name":"RouterOutletMap"},{"provide":{"__symbolic":"reference","module":"./router_state","name":"ActivatedRoute"},"useFactory":{"__symbolic":"reference","name":"rootRoute"},"deps":[{"__symbolic":"reference","module":"./router","name":"Router"}]},{"provide":{"__symbolic":"reference","module":"@angular/core","name":"NgModuleFactoryLoader"},"useClass":{"__symbolic":"reference","module":"@angular/core","name":"SystemJsNgModuleLoader"}},{"__symbolic":"reference","module":"./router_preloader","name":"RouterPreloader"},{"__symbolic":"reference","module":"./router_preloader","name":"NoPreloading"},{"__symbolic":"reference","module":"./router_preloader","name":"PreloadAllModules"},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},"useValue":{"enableTracing":false}}],"RouterModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./directives/router_outlet","name":"RouterOutlet"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLink"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLinkWithHref"},{"__symbolic":"reference","module":"./directives/router_link_active","name":"RouterLinkActive"}],"exports":[{"__symbolic":"reference","module":"./directives/router_outlet","name":"RouterOutlet"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLink"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLinkWithHref"},{"__symbolic":"reference","module":"./directives/router_link_active","name":"RouterLinkActive"}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"ROUTER_FORROOT_GUARD"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}]},"statics":{"forRoot":{"__symbolic":"function","parameters":["routes","config"],"value":{"ngModule":{"__symbolic":"reference","name":"RouterModule"},"providers":[{"__symbolic":"reference","name":"ROUTER_PROVIDERS"},{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRoutes"},"arguments":[{"__symbolic":"reference","name":"routes"}]},{"provide":{"__symbolic":"reference","name":"ROUTER_FORROOT_GUARD"},"useFactory":{"__symbolic":"reference","name":"provideForRootGuard"},"deps":[[{"__symbolic":"reference","module":"./router","name":"Router"},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf"}}]]},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},"useValue":{"__symbolic":"if","condition":{"__symbolic":"reference","name":"config"},"thenExpression":{"__symbolic":"reference","name":"config"},"elseExpression":{}}},{"provide":{"__symbolic":"reference","module":"@angular/common","name":"LocationStrategy"},"useFactory":{"__symbolic":"reference","name":"provideLocationStrategy"},"deps":[{"__symbolic":"reference","module":"@angular/common","name":"PlatformLocation"},[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/common","name":"APP_BASE_HREF"}]},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}}],{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"}]},{"provide":{"__symbolic":"reference","module":"./router_preloader","name":"PreloadingStrategy"},"useExisting":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"config"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"preloadingStrategy"}},"thenExpression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"preloadingStrategy"},"elseExpression":{"__symbolic":"reference","module":"./router_preloader","name":"NoPreloading"}}},{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRouterInitializer"}}]}},"forChild":{"__symbolic":"function","parameters":["routes"],"value":{"ngModule":{"__symbolic":"reference","name":"RouterModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRoutes"},"arguments":[{"__symbolic":"reference","name":"routes"}]}]}}}},"provideLocationStrategy":{"__symbolic":"function","parameters":["platformLocationStrategy","baseHref","options"],"value":{"__symbolic":"if","condition":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"useHash"},"thenExpression":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/common","name":"HashLocationStrategy"},"arguments":[{"__symbolic":"reference","name":"platformLocationStrategy"},{"__symbolic":"reference","name":"baseHref"}]},"elseExpression":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/common","name":"PathLocationStrategy"},"arguments":[{"__symbolic":"reference","name":"platformLocationStrategy"},{"__symbolic":"reference","name":"baseHref"}]}},"defaults":[null,null,{}]},"provideRoutes":{"__symbolic":"function","parameters":["routes"],"value":[{"provide":{"__symbolic":"reference","module":"@angular/core","name":"ANALYZE_FOR_ENTRY_COMPONENTS"},"multi":true,"useValue":{"__symbolic":"reference","name":"routes"}},{"provide":{"__symbolic":"reference","module":"./router_config_loader","name":"ROUTES"},"multi":true,"useValue":{"__symbolic":"reference","name":"routes"}}]},"rootRoute":{"__symbolic":"function","parameters":["router"],"value":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"router"},"member":"routerState"},"member":"root"}},"initialRouterNavigation":{"__symbolic":"function","parameters":["router","ref","preloader","opts"],"value":{"__symbolic":"error","message":"Function call not supported","line":269,"character":9}},"provideRouterInitializer":{"__symbolic":"function","parameters":[],"value":{"provide":{"__symbolic":"reference","module":"@angular/core","name":"APP_BOOTSTRAP_LISTENER"},"multi":true,"useFactory":{"__symbolic":"reference","name":"initialRouterNavigation"},"deps":[{"__symbolic":"reference","module":"./router","name":"Router"},{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef"},{"__symbolic":"reference","module":"./router_preloader","name":"RouterPreloader"},{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"}]}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"ROUTER_CONFIGURATION":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["ROUTER_CONFIGURATION"]},"ROUTER_FORROOT_GUARD":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["ROUTER_FORROOT_GUARD"]},"ROUTER_PROVIDERS":[{"__symbolic":"reference","module":"@angular/common","name":"Location"},{"provide":{"__symbolic":"reference","module":"./url_tree","name":"UrlSerializer"},"useClass":{"__symbolic":"reference","module":"./url_tree","name":"DefaultUrlSerializer"}},{"provide":{"__symbolic":"reference","module":"./router","name":"Router"},"useFactory":{"__symbolic":"reference","name":"setupRouter"},"deps":[{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef"},{"__symbolic":"reference","module":"./url_tree","name":"UrlSerializer"},{"__symbolic":"reference","module":"./router_outlet_map","name":"RouterOutletMap"},{"__symbolic":"reference","module":"@angular/common","name":"Location"},{"__symbolic":"reference","module":"@angular/core","name":"Injector"},{"__symbolic":"reference","module":"@angular/core","name":"NgModuleFactoryLoader"},{"__symbolic":"reference","module":"@angular/core","name":"Compiler"},{"__symbolic":"reference","module":"./router_config_loader","name":"ROUTES"},{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},[{"__symbolic":"reference","module":"./url_handling_strategy","name":"UrlHandlingStrategy"},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}}]]},{"__symbolic":"reference","module":"./router_outlet_map","name":"RouterOutletMap"},{"provide":{"__symbolic":"reference","module":"./router_state","name":"ActivatedRoute"},"useFactory":{"__symbolic":"reference","name":"rootRoute"},"deps":[{"__symbolic":"reference","module":"./router","name":"Router"}]},{"provide":{"__symbolic":"reference","module":"@angular/core","name":"NgModuleFactoryLoader"},"useClass":{"__symbolic":"reference","module":"@angular/core","name":"SystemJsNgModuleLoader"}},{"__symbolic":"reference","module":"./router_preloader","name":"RouterPreloader"},{"__symbolic":"reference","module":"./router_preloader","name":"NoPreloading"},{"__symbolic":"reference","module":"./router_preloader","name":"PreloadAllModules"},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},"useValue":{"enableTracing":false}}],"RouterModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule"},"arguments":[{"declarations":[{"__symbolic":"reference","module":"./directives/router_outlet","name":"RouterOutlet"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLink"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLinkWithHref"},{"__symbolic":"reference","module":"./directives/router_link_active","name":"RouterLinkActive"}],"exports":[{"__symbolic":"reference","module":"./directives/router_outlet","name":"RouterOutlet"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLink"},{"__symbolic":"reference","module":"./directives/router_link","name":"RouterLinkWithHref"},{"__symbolic":"reference","module":"./directives/router_link_active","name":"RouterLinkActive"}]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","name":"ROUTER_FORROOT_GUARD"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}]},"statics":{"forRoot":{"__symbolic":"function","parameters":["routes","config"],"value":{"ngModule":{"__symbolic":"reference","name":"RouterModule"},"providers":[{"__symbolic":"reference","name":"ROUTER_PROVIDERS"},{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRoutes"},"arguments":[{"__symbolic":"reference","name":"routes"}]},{"provide":{"__symbolic":"reference","name":"ROUTER_FORROOT_GUARD"},"useFactory":{"__symbolic":"reference","name":"provideForRootGuard"},"deps":[[{"__symbolic":"reference","module":"./router","name":"Router"},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf"}}]]},{"provide":{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"},"useValue":{"__symbolic":"if","condition":{"__symbolic":"reference","name":"config"},"thenExpression":{"__symbolic":"reference","name":"config"},"elseExpression":{}}},{"provide":{"__symbolic":"reference","module":"@angular/common","name":"LocationStrategy"},"useFactory":{"__symbolic":"reference","name":"provideLocationStrategy"},"deps":[{"__symbolic":"reference","module":"@angular/common","name":"PlatformLocation"},[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject"},"arguments":[{"__symbolic":"reference","module":"@angular/common","name":"APP_BASE_HREF"}]},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional"}}],{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"}]},{"provide":{"__symbolic":"reference","module":"./router_preloader","name":"PreloadingStrategy"},"useExisting":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"config"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"preloadingStrategy"}},"thenExpression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"config"},"member":"preloadingStrategy"},"elseExpression":{"__symbolic":"reference","module":"./router_preloader","name":"NoPreloading"}}},{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRouterInitializer"}}]}},"forChild":{"__symbolic":"function","parameters":["routes"],"value":{"ngModule":{"__symbolic":"reference","name":"RouterModule"},"providers":[{"__symbolic":"call","expression":{"__symbolic":"reference","name":"provideRoutes"},"arguments":[{"__symbolic":"reference","name":"routes"}]}]}}}},"provideLocationStrategy":{"__symbolic":"function","parameters":["platformLocationStrategy","baseHref","options"],"value":{"__symbolic":"if","condition":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"useHash"},"thenExpression":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/common","name":"HashLocationStrategy"},"arguments":[{"__symbolic":"reference","name":"platformLocationStrategy"},{"__symbolic":"reference","name":"baseHref"}]},"elseExpression":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/common","name":"PathLocationStrategy"},"arguments":[{"__symbolic":"reference","name":"platformLocationStrategy"},{"__symbolic":"reference","name":"baseHref"}]}},"defaults":[null,null,{}]},"provideRoutes":{"__symbolic":"function","parameters":["routes"],"value":[{"provide":{"__symbolic":"reference","module":"@angular/core","name":"ANALYZE_FOR_ENTRY_COMPONENTS"},"multi":true,"useValue":{"__symbolic":"reference","name":"routes"}},{"provide":{"__symbolic":"reference","module":"./router_config_loader","name":"ROUTES"},"multi":true,"useValue":{"__symbolic":"reference","name":"routes"}}]},"rootRoute":{"__symbolic":"function","parameters":["router"],"value":{"__symbolic":"select","expression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"router"},"member":"routerState"},"member":"root"}},"initialRouterNavigation":{"__symbolic":"function","parameters":["router","ref","preloader","opts"],"value":{"__symbolic":"error","message":"Function call not supported","line":269,"character":9}},"ROUTER_INITIALIZER":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"OpaqueToken"},"arguments":["Router Initializer"]},"provideRouterInitializer":{"__symbolic":"function","parameters":[],"value":[{"provide":{"__symbolic":"reference","name":"ROUTER_INITIALIZER"},"useFactory":{"__symbolic":"reference","name":"initialRouterNavigation"},"deps":[{"__symbolic":"reference","module":"./router","name":"Router"},{"__symbolic":"reference","module":"@angular/core","name":"ApplicationRef"},{"__symbolic":"reference","module":"./router_preloader","name":"RouterPreloader"},{"__symbolic":"reference","name":"ROUTER_CONFIGURATION"}]},{"provide":{"__symbolic":"reference","module":"@angular/core","name":"APP_BOOTSTRAP_LISTENER"},"multi":true,"useExisting":{"__symbolic":"reference","name":"ROUTER_INITIALIZER"}}]}}} |
@@ -55,2 +55,4 @@ /** | ||
* If a route is protected by `canLoad` guards, the preloaded will not load it. | ||
* | ||
* @stable | ||
*/ | ||
@@ -57,0 +59,0 @@ export declare class RouterPreloader { |
@@ -71,2 +71,4 @@ /** | ||
* If a route is protected by `canLoad` guards, the preloaded will not load it. | ||
* | ||
* @stable | ||
*/ | ||
@@ -73,0 +75,0 @@ export var RouterPreloader = (function () { |
@@ -428,2 +428,3 @@ /** | ||
isActive(url: string | UrlTree, exact: boolean): boolean; | ||
private removeEmptyProps(params); | ||
private processNavigations(); | ||
@@ -430,0 +431,0 @@ private scheduleNavigation(rawUrl, extras); |
@@ -15,4 +15,4 @@ /** | ||
import { every } from 'rxjs/operator/every'; | ||
import { first } from 'rxjs/operator/first'; | ||
import { map } from 'rxjs/operator/map'; | ||
import { mergeAll } from 'rxjs/operator/mergeAll'; | ||
import { mergeMap } from 'rxjs/operator/mergeMap'; | ||
@@ -378,2 +378,5 @@ import { reduce } from 'rxjs/operator/reduce'; | ||
if (extras === void 0) { extras = { skipLocationChange: false }; } | ||
if (typeof extras.queryParams === 'object' && extras.queryParams !== null) { | ||
extras.queryParams = this.removeEmptyProps(extras.queryParams); | ||
} | ||
return this.navigateByUrl(this.createUrlTree(commands, extras), extras); | ||
@@ -401,2 +404,11 @@ }; | ||
}; | ||
Router.prototype.removeEmptyProps = function (params) { | ||
return Object.keys(params).reduce(function (result, key) { | ||
var value = params[key]; | ||
if (value !== null && value !== undefined) { | ||
result[key] = value; | ||
} | ||
return result; | ||
}, {}); | ||
}; | ||
Router.prototype.processNavigations = function () { | ||
@@ -431,3 +443,5 @@ var _this = this; | ||
this.navigations.next({ id: id, rawUrl: rawUrl, prevRawUrl: prevRawUrl, extras: extras, resolve: resolve, reject: reject, promise: promise }); | ||
return promise; | ||
// Make sure that the error is propagated even though `processNavigations` catch | ||
// handler does not rethrow | ||
return promise.catch(function (e) { return Promise.reject(e); }); | ||
}; | ||
@@ -607,3 +621,3 @@ Router.prototype.executeScheduledNavigation = function (_a) { | ||
var checks$ = from(this.checks); | ||
var runningChecks$ = map.call(checks$, function (s) { | ||
var runningChecks$ = mergeMap.call(checks$, function (s) { | ||
if (s instanceof CanActivate) { | ||
@@ -621,4 +635,3 @@ return andObservables(from([_this.runCanActivateChild(s.path), _this.runCanActivate(s.route)])); | ||
}); | ||
var mergedChecks$ = mergeAll.call(runningChecks$); | ||
return every.call(mergedChecks$, function (result) { return result === true; }); | ||
return every.call(runningChecks$, function (result) { return result === true; }); | ||
}; | ||
@@ -717,8 +730,10 @@ PreActivation.prototype.resolveData = function () { | ||
var guard = _this.getToken(c, future); | ||
var observable; | ||
if (guard.canActivate) { | ||
return wrapIntoObservable(guard.canActivate(future, _this.future)); | ||
observable = wrapIntoObservable(guard.canActivate(future, _this.future)); | ||
} | ||
else { | ||
return wrapIntoObservable(guard(future, _this.future)); | ||
observable = wrapIntoObservable(guard(future, _this.future)); | ||
} | ||
return first.call(observable); | ||
}); | ||
@@ -737,8 +752,10 @@ return andObservables(obs); | ||
var guard = _this.getToken(c, c.node); | ||
var observable; | ||
if (guard.canActivateChild) { | ||
return wrapIntoObservable(guard.canActivateChild(future, _this.future)); | ||
observable = wrapIntoObservable(guard.canActivateChild(future, _this.future)); | ||
} | ||
else { | ||
return wrapIntoObservable(guard(future, _this.future)); | ||
observable = wrapIntoObservable(guard(future, _this.future)); | ||
} | ||
return first.call(observable); | ||
}); | ||
@@ -759,13 +776,14 @@ return andObservables(obs); | ||
return of(true); | ||
var canDeactivate$ = map.call(from(canDeactivate), function (c) { | ||
var canDeactivate$ = mergeMap.call(from(canDeactivate), function (c) { | ||
var guard = _this.getToken(c, curr); | ||
var observable; | ||
if (guard.canDeactivate) { | ||
return wrapIntoObservable(guard.canDeactivate(component, curr, _this.curr)); | ||
observable = wrapIntoObservable(guard.canDeactivate(component, curr, _this.curr)); | ||
} | ||
else { | ||
return wrapIntoObservable(guard(component, curr, _this.curr)); | ||
observable = wrapIntoObservable(guard(component, curr, _this.curr)); | ||
} | ||
return first.call(observable); | ||
}); | ||
var merged$ = mergeAll.call(canDeactivate$); | ||
return every.call(merged$, function (result) { return result === true; }); | ||
return every.call(canDeactivate$, function (result) { return result === true; }); | ||
}; | ||
@@ -803,10 +821,11 @@ PreActivation.prototype.runResolve = function (future) { | ||
var currRoot = this.currState ? this.currState._root : null; | ||
this.deactivateChildRoutes(futureRoot, currRoot, parentOutletMap); | ||
advanceActivatedRoute(this.futureState.root); | ||
this.activateChildRoutes(futureRoot, currRoot, parentOutletMap); | ||
}; | ||
ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, outletMap) { | ||
ActivateRoutes.prototype.deactivateChildRoutes = function (futureNode, currNode, outletMap) { | ||
var _this = this; | ||
var prevChildren = nodeChildrenAsMap(currNode); | ||
futureNode.children.forEach(function (c) { | ||
_this.activateRoutes(c, prevChildren[c.value.outlet], outletMap); | ||
_this.deactivateRoutes(c, prevChildren[c.value.outlet], outletMap); | ||
delete prevChildren[c.value.outlet]; | ||
@@ -816,2 +835,27 @@ }); | ||
}; | ||
ActivateRoutes.prototype.activateChildRoutes = function (futureNode, currNode, outletMap) { | ||
var _this = this; | ||
var prevChildren = nodeChildrenAsMap(currNode); | ||
futureNode.children.forEach(function (c) { _this.activateRoutes(c, prevChildren[c.value.outlet], outletMap); }); | ||
}; | ||
ActivateRoutes.prototype.deactivateRoutes = function (futureNode, currNode, parentOutletMap) { | ||
var future = futureNode.value; | ||
var curr = currNode ? currNode.value : null; | ||
// reusing the node | ||
if (future === curr) { | ||
// If we have a normal route, we need to go through an outlet. | ||
if (future.component) { | ||
var outlet = getOutlet(parentOutletMap, future); | ||
this.deactivateChildRoutes(futureNode, currNode, outlet.outletMap); | ||
} | ||
else { | ||
this.deactivateChildRoutes(futureNode, currNode, parentOutletMap); | ||
} | ||
} | ||
else { | ||
if (curr) { | ||
this.deactiveRouteAndItsChildren(currNode, parentOutletMap); | ||
} | ||
} | ||
}; | ||
ActivateRoutes.prototype.activateRoutes = function (futureNode, currNode, parentOutletMap) { | ||
@@ -834,5 +878,2 @@ var future = futureNode.value; | ||
else { | ||
if (curr) { | ||
this.deactiveRouteAndItsChildren(currNode, parentOutletMap); | ||
} | ||
// if we have a normal route, we need to advance the route | ||
@@ -859,10 +900,14 @@ // and place the component into the outlet. After that recurse. | ||
var config = parentLoadedConfig(future.snapshot); | ||
var loadedFactoryResolver = null; | ||
var loadedInjector = null; | ||
var resolver = null; | ||
var injector = null; | ||
if (config) { | ||
loadedFactoryResolver = config.factoryResolver; | ||
loadedInjector = config.injector; | ||
resolved.push({ provide: ComponentFactoryResolver, useValue: loadedFactoryResolver }); | ||
injector = config.injectorFactory(outlet.locationInjector); | ||
resolver = config.factoryResolver; | ||
resolved.push({ provide: ComponentFactoryResolver, useValue: resolver }); | ||
} | ||
outlet.activate(future, loadedFactoryResolver, loadedInjector, ReflectiveInjector.resolve(resolved), outletMap); | ||
else { | ||
injector = outlet.locationInjector; | ||
resolver = outlet.locationFactoryResolver; | ||
} | ||
outlet.activate(future, resolver, injector, ReflectiveInjector.resolve(resolved), outletMap); | ||
}; | ||
@@ -869,0 +914,0 @@ ActivateRoutes.prototype.deactiveRouteAndItsChildren = function (route, parentOutletMap) { |
@@ -9,2 +9,4 @@ | ||
*/ | ||
import { Route, UrlMatchResult } from './config'; | ||
import { UrlSegment, UrlSegmentGroup } from './url_tree'; | ||
/** | ||
@@ -30,1 +32,2 @@ * @whatItDoes Name of the primary outlet. | ||
} | ||
export declare function defaultUrlMatcher(segments: UrlSegment[], segmentGroup: UrlSegmentGroup, route: Route): UrlMatchResult; |
@@ -29,2 +29,30 @@ /** | ||
}(Error)); | ||
export function defaultUrlMatcher(segments, segmentGroup, route) { | ||
var path = route.path; | ||
var parts = path.split('/'); | ||
var posParams = {}; | ||
var consumed = []; | ||
var currentIndex = 0; | ||
for (var i = 0; i < parts.length; ++i) { | ||
if (currentIndex >= segments.length) | ||
return null; | ||
var current = segments[currentIndex]; | ||
var p = parts[i]; | ||
var isPosParam = p.startsWith(':'); | ||
if (!isPosParam && p !== current.path) | ||
return null; | ||
if (isPosParam) { | ||
posParams[p.substring(1)] = current; | ||
} | ||
consumed.push(current); | ||
currentIndex++; | ||
} | ||
if (route.pathMatch === 'full' && | ||
(segmentGroup.hasChildren() || currentIndex < segments.length)) { | ||
return null; | ||
} | ||
else { | ||
return { consumed: consumed, posParams: posParams }; | ||
} | ||
} | ||
//# sourceMappingURL=shared.js.map |
@@ -125,3 +125,3 @@ export declare function createEmptyUrlTree(): UrlTree; | ||
/** | ||
* The part part of a URL segment. | ||
* The path part of a URL segment. | ||
*/ | ||
@@ -137,3 +137,3 @@ path: string; | ||
/** | ||
* The part part of a URL segment. | ||
* The path part of a URL segment. | ||
*/ | ||
@@ -140,0 +140,0 @@ path: string, |
@@ -15,8 +15,13 @@ /** | ||
if (exact) { | ||
return equalSegmentGroups(container.root, containee.root); | ||
return equalQueryParams(container.queryParams, containee.queryParams) && | ||
equalSegmentGroups(container.root, containee.root); | ||
} | ||
else { | ||
return containsSegmentGroup(container.root, containee.root); | ||
return containsQueryParams(container.queryParams, containee.queryParams) && | ||
containsSegmentGroup(container.root, containee.root); | ||
} | ||
} | ||
function equalQueryParams(container, containee) { | ||
return shallowEqual(container, containee); | ||
} | ||
function equalSegmentGroups(container, containee) { | ||
@@ -35,2 +40,6 @@ if (!equalPath(container.segments, containee.segments)) | ||
} | ||
function containsQueryParams(container, containee) { | ||
return Object.keys(containee) <= Object.keys(container) && | ||
Object.keys(containee).every(function (key) { return containee[key] === container[key]; }); | ||
} | ||
function containsSegmentGroup(container, containee) { | ||
@@ -197,3 +206,3 @@ return containsSegmentGroupHelper(container, containee, containee.segments); | ||
/** | ||
* The part part of a URL segment. | ||
* The path part of a URL segment. | ||
*/ | ||
@@ -200,0 +209,0 @@ path, |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":1,"metadata":{"createEmptyUrlTree":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"UrlTree"},"arguments":[{"__symbolic":"new","expression":{"__symbolic":"reference","name":"UrlSegmentGroup"},"arguments":[[],{}]},{},null]}},"serializePaths":{"__symbolic":"function","parameters":["segment"],"value":{"__symbolic":"error","message":"Function call not supported","line":308,"character":30}},"encode":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"encodeURIComponent"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"decode":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"decodeURIComponent"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"serializePath":{"__symbolic":"function","parameters":["path"],"value":{"__symbolic":"error","message":"Expression form not supported","line":352,"character":9}}}} | ||
{"__symbolic":"module","version":1,"metadata":{"createEmptyUrlTree":{"__symbolic":"function","parameters":[],"value":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"UrlTree"},"arguments":[{"__symbolic":"new","expression":{"__symbolic":"reference","name":"UrlSegmentGroup"},"arguments":[[],{}]},{},null]}},"serializePaths":{"__symbolic":"function","parameters":["segment"],"value":{"__symbolic":"error","message":"Function call not supported","line":321,"character":30}},"encode":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"encodeURIComponent"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"decode":{"__symbolic":"function","parameters":["s"],"value":{"__symbolic":"call","expression":{"__symbolic":"reference","name":"decodeURIComponent"},"arguments":[{"__symbolic":"reference","name":"s"}]}},"serializePath":{"__symbolic":"function","parameters":["path"],"value":{"__symbolic":"error","message":"Expression form not supported","line":365,"character":9}}}} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
881674
113
11642
5