Skip to content

Commit ded49b7

Browse files
committed
cleanup
1 parent b7d8e63 commit ded49b7

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

modules/change_detection/src/abstract_change_detector.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,6 @@ export class AbstractChangeDetector extends ChangeDetector {
4242
if (this.mode === CHECK_ONCE) this.mode = CHECKED;
4343
}
4444

45-
markAsCheckOnce(){
46-
var c = this;
47-
while(isPresent(c) && (c.mode === CHECKED || c.mode === CHECK_ALWAYS)) {
48-
if (c.mode === CHECKED) c.mode = CHECK_ONCE;
49-
c = c.parent;
50-
}
51-
}
52-
5345
detectChangesInRecords(throwOnChange:boolean){}
5446

5547
_detectChangesInChildren(throwOnChange:boolean) {

modules/change_detection/src/change_detection_util.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {ArrayChanges} from './array_changes';
55
import {KeyValueChanges} from './keyvalue_changes';
66
import {ProtoRecord} from './proto_change_detector';
77
import {ExpressionChangedAfterItHasBeenChecked} from './exceptions';
8-
import {ChangeRecord} from './interfaces';
8+
import {ChangeRecord, ChangeDetector, CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED} from './interfaces';
99

1010
export var uninitialized = new Object();
1111

@@ -214,4 +214,12 @@ export class ChangeDetectionUtil {
214214
}
215215
return updatedRecords;
216216
}
217+
218+
static markPathToRootAsCheckOnce(cd:ChangeDetector) {
219+
var c = cd;
220+
while(isPresent(c) && c.mode != DETACHED) {
221+
if (c.mode === CHECKED) c.mode = CHECK_ONCE;
222+
c = c.parent;
223+
}
224+
}
217225
}

modules/change_detection/src/interfaces.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export class ChangeDetector {
5656
removeChild(cd:ChangeDetector) {}
5757
remove() {}
5858
setContext(context:any) {}
59+
markPathToRootAsCheckOnce() {}
5960

6061
detectChanges() {}
6162
checkNoChanges() {}

modules/change_detection/test/change_detection_spec.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ import {Lexer} from 'change_detection/src/parser/lexer';
88
import {reflector} from 'reflection/src/reflection';
99
import {arrayChangesAsString, kvChangesAsString} from './util';
1010

11-
import {ChangeDispatcher, DynamicChangeDetector, ChangeDetectionError, ContextWithVariableBindings}
12-
from 'change_detection/change_detection';
11+
import {ChangeDispatcher, DynamicChangeDetector, ChangeDetectionError, ContextWithVariableBindings,
12+
CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED} from 'change_detection/change_detection';
1313

1414

1515
import {JitProtoChangeDetector, DynamicProtoChangeDetector} from 'change_detection/src/proto_change_detector';
16-
import {CHECK_ALWAYS, CHECK_ONCE, CHECKED, DETACHED} from 'change_detection/src/interfaces';
16+
import {ChangeDetectionUtil} from 'change_detection/src/change_detection_util';
1717

1818

1919
export function main() {
@@ -517,7 +517,7 @@ export function main() {
517517
});
518518
});
519519

520-
describe("markAsCheckOnce", () => {
520+
describe("markPathToRootAsCheckOnce", () => {
521521
function changeDetector(mode, parent) {
522522
var cd = createProtoChangeDetector().instantiate(null, null);
523523
cd.mode = mode;
@@ -531,16 +531,18 @@ export function main() {
531531
var root = changeDetector(CHECK_ALWAYS, null);
532532
var disabled = changeDetector(DETACHED, root);
533533
var parent = changeDetector(CHECKED, disabled);
534-
var child = changeDetector(CHECK_ALWAYS, parent);
535-
var grandChild = changeDetector(CHECKED, child);
534+
var checkAlwaysChild = changeDetector(CHECK_ALWAYS, parent);
535+
var checkOnceChild = changeDetector(CHECK_ONCE, checkAlwaysChild);
536+
var checkedChild = changeDetector(CHECKED, checkOnceChild);
536537

537-
grandChild.markAsCheckOnce();
538+
ChangeDetectionUtil.markPathToRootAsCheckOnce(checkedChild);
538539

539540
expect(root.mode).toEqual(CHECK_ALWAYS);
540541
expect(disabled.mode).toEqual(DETACHED);
541542
expect(parent.mode).toEqual(CHECK_ONCE);
542-
expect(child.mode).toEqual(CHECK_ALWAYS);
543-
expect(grandChild.mode).toEqual(CHECK_ONCE);
543+
expect(checkAlwaysChild.mode).toEqual(CHECK_ALWAYS);
544+
expect(checkOnceChild.mode).toEqual(CHECK_ONCE);
545+
expect(checkedChild.mode).toEqual(CHECK_ONCE);
544546
});
545547
});
546548
});

modules/core/src/compiler/binding_propagation_config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class BindingPropagationConfig {
1212
}
1313

1414
shouldBePropagatedFromRoot() {
15-
this._cd.markAsCheckOnce();
15+
this._cd.markPathToRootAsCheckOnce();
1616
}
1717

1818
shouldNotPropagate() {

0 commit comments

Comments
 (0)