1- import { ListWrapper } from 'angular2/src/core/facade/collection' ;
21import { isPresent , isBlank , Type , isArray , isNumber } from 'angular2/src/core/facade/lang' ;
32
43import { RenderProtoViewRef } from 'angular2/src/core/render/api' ;
54
6- import { Injectable , Provider , resolveForwardRef , Inject } from 'angular2/src/core/di' ;
5+ import { Optional , Injectable , Provider , resolveForwardRef , Inject } from 'angular2/src/core/di' ;
76
87import { PipeProvider } from '../pipes/pipe_provider' ;
98import { ProtoPipes } from '../pipes/pipes' ;
@@ -15,7 +14,7 @@ import {DirectiveResolver} from './directive_resolver';
1514import { ViewResolver } from './view_resolver' ;
1615import { PipeResolver } from './pipe_resolver' ;
1716import { ViewMetadata } from '../metadata/view' ;
18- import { DEFAULT_PIPES_TOKEN } from 'angular2/src/core/pipes ' ;
17+ import { AMBIENT_PIPES } from 'angular2/src/core/compiler/ambient ' ;
1918
2019import {
2120 visitAllCommands ,
@@ -38,15 +37,10 @@ import {APP_ID} from 'angular2/src/core/application_tokens';
3837@Injectable ( )
3938export class ProtoViewFactory {
4039 private _cache : Map < number , AppProtoView > = new Map < number , AppProtoView > ( ) ;
41- private _defaultPipes : Type [ ] ;
42- private _appId : string ;
43-
44- constructor ( private _renderer : Renderer , @Inject ( DEFAULT_PIPES_TOKEN ) defaultPipes : Type [ ] ,
40+ constructor ( private _renderer : Renderer ,
41+ @Optional ( ) @Inject ( AMBIENT_PIPES ) private _ambientPipes : Array < Type | any [ ] > ,
4542 private _directiveResolver : DirectiveResolver , private _viewResolver : ViewResolver ,
46- private _pipeResolver : PipeResolver , @Inject ( APP_ID ) appId : string ) {
47- this . _defaultPipes = defaultPipes ;
48- this . _appId = appId ;
49- }
43+ private _pipeResolver : PipeResolver , @Inject ( APP_ID ) private _appId : string ) { }
5044
5145 clearCache ( ) { this . _cache . clear ( ) ; }
5246
@@ -118,9 +112,13 @@ export class ProtoViewFactory {
118112 }
119113
120114 private _flattenPipes ( view : ViewMetadata ) : any [ ] {
121- if ( isBlank ( view . pipes ) ) return this . _defaultPipes ;
122- var pipes = ListWrapper . clone ( this . _defaultPipes ) ;
123- _flattenList ( view . pipes , pipes ) ;
115+ let pipes = [ ] ;
116+ if ( isPresent ( this . _ambientPipes ) ) {
117+ _flattenArray ( this . _ambientPipes , pipes ) ;
118+ }
119+ if ( isPresent ( view . pipes ) ) {
120+ _flattenArray ( view . pipes , pipes ) ;
121+ }
124122 return pipes ;
125123 }
126124}
@@ -313,11 +311,11 @@ function arrayToMap(arr: string[], inverse: boolean): Map<string, string> {
313311 return result ;
314312}
315313
316- function _flattenList ( tree : any [ ] , out : Array < Type | Provider | any [ ] > ) : void {
314+ function _flattenArray ( tree : any [ ] , out : Array < Type | Provider | any [ ] > ) : void {
317315 for ( var i = 0 ; i < tree . length ; i ++ ) {
318316 var item = resolveForwardRef ( tree [ i ] ) ;
319317 if ( isArray ( item ) ) {
320- _flattenList ( item , out ) ;
318+ _flattenArray ( item , out ) ;
321319 } else {
322320 out . push ( item ) ;
323321 }
0 commit comments