File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88
99import { Type } from '@angular/core' ;
1010import { Observable } from 'rxjs/Observable' ;
11-
11+ import { PRIMARY_OUTLET } from './shared' ;
1212
1313/**
1414 * @whatItDoes Represents router configuration.
@@ -320,6 +320,10 @@ function validateNode(route: Route): void {
320320 if ( Array . isArray ( route ) ) {
321321 throw new Error ( `Invalid route configuration: Array cannot be specified` ) ;
322322 }
323+ if ( route . component === undefined && ( route . outlet && route . outlet !== PRIMARY_OUTLET ) ) {
324+ throw new Error (
325+ `Invalid route configuration of route '${ route . path } ': a componentless route cannot have a named outlet set` ) ;
326+ }
323327 if ( ! ! route . redirectTo && ! ! route . children ) {
324328 throw new Error (
325329 `Invalid configuration of route '${ route . path } ': redirectTo and children cannot be used together` ) ;
Original file line number Diff line number Diff line change @@ -12,8 +12,6 @@ import {RouterOutletMap} from '../router_outlet_map';
1212import { ActivatedRoute } from '../router_state' ;
1313import { PRIMARY_OUTLET } from '../shared' ;
1414
15-
16-
1715/**
1816 * @whatItDoes Acts as a placeholder that Angular dynamically fills based on the current router
1917 * state.
@@ -79,6 +77,10 @@ export class RouterOutlet implements OnDestroy {
7977 activatedRoute : ActivatedRoute , loadedResolver : ComponentFactoryResolver ,
8078 loadedInjector : Injector , providers : ResolvedReflectiveProvider [ ] ,
8179 outletMap : RouterOutletMap ) : void {
80+ if ( this . isActivated ) {
81+ throw new Error ( 'Cannot activate an already activated outlet' ) ;
82+ }
83+
8284 this . outletMap = outletMap ;
8385 this . _activatedRoute = activatedRoute ;
8486
Original file line number Diff line number Diff line change 77 */
88
99import { validateConfig } from '../src/config' ;
10+ import { PRIMARY_OUTLET } from '../src/shared' ;
1011
1112describe ( 'config' , ( ) => {
1213 describe ( 'validateConfig' , ( ) => {
@@ -80,6 +81,16 @@ describe('config', () => {
8081 . toThrowError (
8182 / I n v a l i d c o n f i g u r a t i o n o f r o u t e ' a ' : p a t h M a t c h c a n o n l y b e s e t t o ' p r e f i x ' o r ' f u l l ' / ) ;
8283 } ) ;
84+
85+ it ( 'should throw when pathPatch is invalid' , ( ) => {
86+ expect ( ( ) => { validateConfig ( [ { path : 'a' , outlet : 'aux' , children : [ ] } ] ) ; } )
87+ . toThrowError (
88+ / I n v a l i d r o u t e c o n f i g u r a t i o n o f r o u t e ' a ' : a c o m p o n e n t l e s s r o u t e c a n n o t h a v e a n a m e d o u t l e t s e t / ) ;
89+
90+ expect ( ( ) => validateConfig ( [ { path : 'a' , outlet : '' , children : [ ] } ] ) ) . not . toThrow ( ) ;
91+ expect ( ( ) => validateConfig ( [ { path : 'a' , outlet : PRIMARY_OUTLET , children : [ ] } ] ) )
92+ . not . toThrow ( ) ;
93+ } ) ;
8394 } ) ;
8495} ) ;
8596
You can’t perform that action at this time.
0 commit comments