From a664f5a6def513c2647a20f595895feb89788ae9 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 18 May 2015 21:29:23 -0700 Subject: [PATCH] fix: don't call onAllChangesDone on checkNoChanges --- .../change_detection/abstract_change_detector.ts | 2 +- .../change_detection/change_detector_spec.js | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/modules/angular2/src/change_detection/abstract_change_detector.ts b/modules/angular2/src/change_detection/abstract_change_detector.ts index fdcee50351..42f3ebaa26 100644 --- a/modules/angular2/src/change_detection/abstract_change_detector.ts +++ b/modules/angular2/src/change_detection/abstract_change_detector.ts @@ -46,7 +46,7 @@ export class AbstractChangeDetector extends ChangeDetector { this._detectChangesInLightDomChildren(throwOnChange); - this.callOnAllChangesDone(); + if (throwOnChange === false) this.callOnAllChangesDone(); this._detectChangesInShadowDomChildren(throwOnChange); diff --git a/modules/angular2/test/change_detection/change_detector_spec.js b/modules/angular2/test/change_detection/change_detector_spec.js index cddf1d435d..8978818cdd 100644 --- a/modules/angular2/test/change_detection/change_detector_spec.js +++ b/modules/angular2/test/change_detection/change_detector_spec.js @@ -339,6 +339,22 @@ export function main() { expect(directive1.onChangesDoneCalled).toBe(true); expect(directive2.onChangesDoneCalled).toBe(true); + + // reset directives + directive1.onChangesDoneCalled = false; + directive2.onChangesDoneCalled = false; + + // Verify that checking should not call them. + cd.checkNoChanges(); + + expect(directive1.onChangesDoneCalled).toBe(false); + expect(directive2.onChangesDoneCalled).toBe(false); + + // re-verify that changes are still detected + cd.detectChanges(); + + expect(directive1.onChangesDoneCalled).toBe(true); + expect(directive2.onChangesDoneCalled).toBe(true); });