@@ -15,10 +15,6 @@ import * as o from '../output/output_ast';
15
15
import { CompileView } from './compile_view' ;
16
16
import { createPureProxy , getPropertyInView , injectFromViewParentInjector } from './util' ;
17
17
18
- class _PurePipeProxy {
19
- constructor ( public view : CompileView , public instance : o . ReadPropExpr , public argCount : number ) { }
20
- }
21
-
22
18
export class CompilePipe {
23
19
static call ( view : CompileView , name : string , args : o . Expression [ ] ) : o . Expression {
24
20
var compView = view . componentView ;
@@ -41,15 +37,10 @@ export class CompilePipe {
41
37
}
42
38
43
39
instance : o . ReadPropExpr ;
44
- private _purePipeProxies : _PurePipeProxy [ ] = [ ] ;
40
+ private _purePipeProxyCount = 0 ;
45
41
46
42
constructor ( public view : CompileView , public meta : CompilePipeMetadata ) {
47
43
this . instance = o . THIS_EXPR . prop ( `_pipe_${ meta . name } _${ view . pipeCount ++ } ` ) ;
48
- }
49
-
50
- get pure ( ) : boolean { return this . meta . pure ; }
51
-
52
- create ( ) : void {
53
44
var deps = this . meta . type . diDeps . map ( ( diDep ) => {
54
45
if ( diDep . token . equalsTo ( identifierToken ( Identifiers . ChangeDetectorRef ) ) ) {
55
46
return getPropertyInView ( o . THIS_EXPR . prop ( 'ref' ) , this . view , this . view . componentView ) ;
@@ -61,28 +52,22 @@ export class CompilePipe {
61
52
this . view . createMethod . addStmt ( o . THIS_EXPR . prop ( this . instance . name )
62
53
. set ( o . importExpr ( this . meta . type ) . instantiate ( deps ) )
63
54
. toStmt ( ) ) ;
64
- this . _purePipeProxies . forEach ( ( purePipeProxy ) => {
65
- var pipeInstanceSeenFromPureProxy =
66
- getPropertyInView ( this . instance , purePipeProxy . view , this . view ) ;
67
- createPureProxy (
68
- pipeInstanceSeenFromPureProxy . prop ( 'transform' )
69
- . callMethod ( o . BuiltinMethod . bind , [ pipeInstanceSeenFromPureProxy ] ) ,
70
- purePipeProxy . argCount , purePipeProxy . instance , purePipeProxy . view ) ;
71
- } ) ;
72
55
}
73
56
57
+ get pure ( ) : boolean { return this . meta . pure ; }
58
+
74
59
private _call ( callingView : CompileView , args : o . Expression [ ] ) : o . Expression {
75
60
if ( this . meta . pure ) {
76
61
// PurePipeProxies live on the view that called them.
77
- var purePipeProxy = new _PurePipeProxy (
78
- callingView , o . THIS_EXPR . prop ( `${ this . instance . name } _${ this . _purePipeProxies . length } ` ) ,
79
- args . length ) ;
80
- this . _purePipeProxies . push ( purePipeProxy ) ;
62
+ var purePipeProxyInstance =
63
+ o . THIS_EXPR . prop ( `${ this . instance . name } _${ this . _purePipeProxyCount ++ } ` ) ;
64
+ var pipeInstanceSeenFromPureProxy = getPropertyInView ( this . instance , callingView , this . view ) ;
65
+ createPureProxy (
66
+ pipeInstanceSeenFromPureProxy . prop ( 'transform' )
67
+ . callMethod ( o . BuiltinMethod . bind , [ pipeInstanceSeenFromPureProxy ] ) ,
68
+ args . length , purePipeProxyInstance , callingView ) ;
81
69
return o . importExpr ( Identifiers . castByValue )
82
- . callFn ( [
83
- purePipeProxy . instance ,
84
- getPropertyInView ( this . instance . prop ( 'transform' ) , callingView , this . view )
85
- ] )
70
+ . callFn ( [ purePipeProxyInstance , pipeInstanceSeenFromPureProxy . prop ( 'transform' ) ] )
86
71
. callFn ( args ) ;
87
72
} else {
88
73
return getPropertyInView ( this . instance , callingView , this . view ) . callMethod ( 'transform' , args ) ;
0 commit comments