@@ -28,7 +28,7 @@ import {DynamicChangeDetector} from './dynamic_change_detector';
2828import { ChangeDetectorJITGenerator } from './change_detection_jit_generator' ;
2929import { PipeRegistry } from './pipes/pipe_registry' ;
3030import { BindingRecord } from './binding_record' ;
31- import { DirectiveIndex } from './directive_record' ;
31+ import { DirectiveRecord , DirectiveIndex } from './directive_record' ;
3232
3333import { coalesce } from './coalesce' ;
3434
@@ -50,25 +50,31 @@ import {
5050export class DynamicProtoChangeDetector extends ProtoChangeDetector {
5151 _pipeRegistry :PipeRegistry ;
5252 _records :List < ProtoRecord > ;
53+ _bindingRecords :List < BindingRecord > ;
54+ _variableBindings :List < string > ;
55+ _directiveRecords :List < DirectiveRecord > ;
5356 _changeControlStrategy :string ;
5457
55- constructor ( pipeRegistry :PipeRegistry , changeControlStrategy :string ) {
58+ constructor ( pipeRegistry :PipeRegistry , bindingRecords : List , variableBindings : List , directiveRecords : List , changeControlStrategy :string ) {
5659 super ( ) ;
5760 this . _pipeRegistry = pipeRegistry ;
61+ this . _bindingRecords = bindingRecords ;
62+ this . _variableBindings = variableBindings ;
63+ this . _directiveRecords = directiveRecords ;
5864 this . _changeControlStrategy = changeControlStrategy ;
5965 }
6066
61- instantiate ( dispatcher :any , bindingRecords : List , variableBindings : List , directiveRecords : List ) {
62- this . _createRecordsIfNecessary ( bindingRecords , variableBindings ) ;
67+ instantiate ( dispatcher :any ) {
68+ this . _createRecordsIfNecessary ( ) ;
6369 return new DynamicChangeDetector ( this . _changeControlStrategy , dispatcher ,
64- this . _pipeRegistry , this . _records , directiveRecords ) ;
70+ this . _pipeRegistry , this . _records , this . _directiveRecords ) ;
6571 }
6672
67- _createRecordsIfNecessary ( bindingRecords : List , variableBindings : List ) {
73+ _createRecordsIfNecessary ( ) {
6874 if ( isBlank ( this . _records ) ) {
6975 var recordBuilder = new ProtoRecordBuilder ( ) ;
70- ListWrapper . forEach ( bindingRecords , ( b ) => {
71- recordBuilder . addAst ( b , variableBindings ) ;
76+ ListWrapper . forEach ( this . _bindingRecords , ( b ) => {
77+ recordBuilder . addAst ( b , this . _variableBindings ) ;
7278 } ) ;
7379 this . _records = coalesce ( recordBuilder . records ) ;
7480 }
@@ -79,31 +85,37 @@ var _jitProtoChangeDetectorClassCounter:number = 0;
7985export class JitProtoChangeDetector extends ProtoChangeDetector {
8086 _factory :Function ;
8187 _pipeRegistry ;
88+ _bindingRecords :List < BindingRecord > ;
89+ _variableBindings :List < string > ;
90+ _directiveRecords :List < DirectiveRecord > ;
8291 _changeControlStrategy :string ;
8392
84- constructor ( pipeRegistry , changeControlStrategy :string ) {
93+ constructor ( pipeRegistry , bindingRecords : List , variableBindings : List , directiveRecords : List , changeControlStrategy :string ) {
8594 super ( ) ;
8695 this . _pipeRegistry = pipeRegistry ;
8796 this . _factory = null ;
97+ this . _bindingRecords = bindingRecords ;
98+ this . _variableBindings = variableBindings ;
99+ this . _directiveRecords = directiveRecords ;
88100 this . _changeControlStrategy = changeControlStrategy ;
89101 }
90102
91- instantiate ( dispatcher :any , bindingRecords : List , variableBindings : List , directiveRecords : List ) {
92- this . _createFactoryIfNecessary ( bindingRecords , variableBindings , directiveRecords ) ;
103+ instantiate ( dispatcher :any ) {
104+ this . _createFactoryIfNecessary ( ) ;
93105 return this . _factory ( dispatcher , this . _pipeRegistry ) ;
94106 }
95107
96- _createFactoryIfNecessary ( bindingRecords : List , variableBindings : List , directiveRecords : List ) {
108+ _createFactoryIfNecessary ( ) {
97109 if ( isBlank ( this . _factory ) ) {
98110 var recordBuilder = new ProtoRecordBuilder ( ) ;
99- ListWrapper . forEach ( bindingRecords , ( b ) => {
100- recordBuilder . addAst ( b , variableBindings ) ;
111+ ListWrapper . forEach ( this . _bindingRecords , ( b ) => {
112+ recordBuilder . addAst ( b , this . _variableBindings ) ;
101113 } ) ;
102114 var c = _jitProtoChangeDetectorClassCounter ++ ;
103115 var records = coalesce ( recordBuilder . records ) ;
104116 var typeName = `ChangeDetector${ c } ` ;
105117 this . _factory = new ChangeDetectorJITGenerator ( typeName , this . _changeControlStrategy , records ,
106- directiveRecords ) . generate ( ) ;
118+ this . _directiveRecords ) . generate ( ) ;
107119 }
108120 }
109121}
0 commit comments