@@ -6,7 +6,7 @@ import {List, ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/faca
66import { Parser } from 'angular2/src/change_detection/parser/parser' ;
77import { Lexer } from 'angular2/src/change_detection/parser/lexer' ;
88
9- import { ChangeDispatcher , DynamicChangeDetector , ChangeDetectionError , ContextWithVariableBindings ,
9+ import { ChangeDispatcher , DynamicChangeDetector , ChangeDetectionError , ContextWithVariableBindings , BindingRecord ,
1010 PipeRegistry , Pipe , NO_CHANGE , CHECK_ALWAYS , CHECK_ONCE , CHECKED , DETACHED } from 'angular2/change_detection' ;
1111
1212import { ChangeDetectionUtil } from 'angular2/src/change_detection/change_detection_util' ;
@@ -30,9 +30,8 @@ export function main() {
3030
3131 function createChangeDetector ( memo :string , exp :string , context = null , registry = null ) {
3232 var pcd = createProtoChangeDetector ( registry ) ;
33- pcd . addAst ( ast ( exp ) , memo , memo ) ;
3433 var dispatcher = new TestDispatcher ( ) ;
35- var cd = pcd . instantiate ( dispatcher ) ;
34+ var cd = pcd . instantiate ( dispatcher , [ new BindingRecord ( ast ( exp ) , memo , memo ) ] ) ;
3635 cd . hydrate ( context ) ;
3736
3837 return { "changeDetector" : cd , "dispatcher" : dispatcher } ;
@@ -179,10 +178,9 @@ export function main() {
179178 var parser = new Parser ( new Lexer ( ) ) ;
180179 var pcd = createProtoChangeDetector ( ) ;
181180 var ast = parser . parseInterpolation ( "B{{a}}A" , "location" ) ;
182- pcd . addAst ( ast , "memo" , "memo" ) ;
183181
184182 var dispatcher = new TestDispatcher ( ) ;
185- var cd = pcd . instantiate ( dispatcher ) ;
183+ var cd = pcd . instantiate ( dispatcher , [ new BindingRecord ( ast , "memo" , "memo" ) ] ) ;
186184 cd . hydrate ( new TestData ( "value" ) ) ;
187185
188186 cd . detectChanges ( ) ;
@@ -230,12 +228,13 @@ export function main() {
230228 describe ( "group changes" , ( ) => {
231229 it ( "should notify the dispatcher when a group of records changes" , ( ) => {
232230 var pcd = createProtoChangeDetector ( ) ;
233- pcd . addAst ( ast ( "1 + 2" ) , "memo" , "1" ) ;
234- pcd . addAst ( ast ( "10 + 20" ) , "memo" , "1" ) ;
235- pcd . addAst ( ast ( "100 + 200" ) , "memo2" , "2" ) ;
236231
237232 var dispatcher = new TestDispatcher ( ) ;
238- var cd = pcd . instantiate ( dispatcher ) ;
233+ var cd = pcd . instantiate ( dispatcher , [
234+ new BindingRecord ( ast ( "1 + 2" ) , "memo" , "1" ) ,
235+ new BindingRecord ( ast ( "10 + 20" ) , "memo" , "1" ) ,
236+ new BindingRecord ( ast ( "100 + 200" ) , "memo" , "2" )
237+ ] ) ;
239238
240239 cd . detectChanges ( ) ;
241240
@@ -244,12 +243,12 @@ export function main() {
244243
245244 it ( "should notify the dispatcher before switching to the next group" , ( ) => {
246245 var pcd = createProtoChangeDetector ( ) ;
247- pcd . addAst ( ast ( "a()" ) , "a" , "1" ) ;
248- pcd . addAst ( ast ( "b()" ) , "b" , "2" ) ;
249- pcd . addAst ( ast ( "c()" ) , "c" , "2" ) ;
250-
251246 var dispatcher = new TestDispatcher ( ) ;
252- var cd = pcd . instantiate ( dispatcher ) ;
247+ var cd = pcd . instantiate ( dispatcher , [
248+ new BindingRecord ( ast ( "a()" ) , "a" , "1" ) ,
249+ new BindingRecord ( ast ( "b()" ) , "b" , "2" ) ,
250+ new BindingRecord ( ast ( "c()" ) , "c" , "2" )
251+ ] ) ;
253252
254253 var tr = new TestRecord ( ) ;
255254 tr . a = ( ) => {
@@ -279,7 +278,9 @@ export function main() {
279278 pcd . addAst ( ast ( "a" ) , "a" , 1 ) ;
280279
281280 var dispatcher = new TestDispatcher ( ) ;
282- var cd = pcd . instantiate ( dispatcher ) ;
281+ var cd = pcd . instantiate ( dispatcher , [
282+ new BindingRecord ( ast ( "a" ) , "a" , 1 )
283+ ] ) ;
283284 cd . hydrate ( new TestData ( 'value' ) ) ;
284285
285286 expect ( ( ) => {
@@ -292,9 +293,9 @@ export function main() {
292293 describe ( "error handling" , ( ) => {
293294 xit ( "should wrap exceptions into ChangeDetectionError" , ( ) => {
294295 var pcd = createProtoChangeDetector ( ) ;
295- pcd . addAst ( ast ( 'invalidProp' , 'someComponent' ) , "a" , 1 ) ;
296-
297- var cd = pcd . instantiate ( new TestDispatcher ( ) ) ;
296+ var cd = pcd . instantiate ( new TestDispatcher ( ) , [
297+ new BindingRecord ( ast ( "invalidProp" , "someComponent" ) , "a" , 1 )
298+ ] ) ;
298299 cd . hydrate ( null ) ;
299300
300301 try {
@@ -349,10 +350,10 @@ export function main() {
349350
350351 beforeEach ( ( ) => {
351352 var protoParent = createProtoChangeDetector ( ) ;
352- parent = protoParent . instantiate ( null ) ;
353+ parent = protoParent . instantiate ( null , [ ] ) ;
353354
354355 var protoChild = createProtoChangeDetector ( ) ;
355- child = protoChild . instantiate ( null ) ;
356+ child = protoChild . instantiate ( null , [ ] ) ;
356357 } ) ;
357358
358359 it ( "should add children" , ( ) => {
@@ -395,7 +396,7 @@ export function main() {
395396 } ) ;
396397
397398 it ( "should change CHECK_ONCE to CHECKED" , ( ) => {
398- var cd = createProtoChangeDetector ( ) . instantiate ( null ) ;
399+ var cd = createProtoChangeDetector ( ) . instantiate ( null , [ ] ) ;
399400 cd . mode = CHECK_ONCE ;
400401
401402 cd . detectChanges ( ) ;
@@ -404,7 +405,7 @@ export function main() {
404405 } ) ;
405406
406407 it ( "should not change the CHECK_ALWAYS" , ( ) => {
407- var cd = createProtoChangeDetector ( ) . instantiate ( null ) ;
408+ var cd = createProtoChangeDetector ( ) . instantiate ( null , [ ] ) ;
408409 cd . mode = CHECK_ALWAYS ;
409410
410411 cd . detectChanges ( ) ;
@@ -415,7 +416,7 @@ export function main() {
415416
416417 describe ( "markPathToRootAsCheckOnce" , ( ) => {
417418 function changeDetector ( mode , parent ) {
418- var cd = createProtoChangeDetector ( ) . instantiate ( null ) ;
419+ var cd = createProtoChangeDetector ( ) . instantiate ( null , [ ] ) ;
419420 cd . mode = mode ;
420421 if ( isPresent ( parent ) ) parent . addChild ( cd ) ;
421422 return cd ;
0 commit comments