Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

fix($compile): ensure that $onChanges hook is called correctly #14355

Closed

Conversation

petebacondarwin
Copy link
Contributor

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

fix

What is the current behavior? (You can also link to an open issue here)

the $onChanges hook is not being called correctly

Please check if the PR fulfills these requirements

Other information:

Due to the way that we instantiate controllers, the $onChanges hook
was not always available at the time we were trying to trigger the initial
call to this hook. For instance, if the hook was actually defined inside
the constructor function.

This commit fixes that but also fixes the fact that the initial call was
being made in the postDigest anyway, which was incorrect because the
it should have been made before the $onInit call.

@petebacondarwin
Copy link
Contributor Author

@mgol does this fix your problem too?

@mgol
Copy link
Member

mgol commented Mar 31, 2016 via email

@@ -3735,7 +3743,10 @@ describe('$compile', function() {
$rootScope.$watch('a', function(val) { $rootScope.b = val * 2; });

// There should be no changes initially
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment no longer applies.

@mgol
Copy link
Member

mgol commented Apr 1, 2016

After removing the one outdated comment, LGTM. 👍

Due to the way that we instantiate controllers, the `$onChanges` hook
was not always available at the time we were trying to trigger the initial
call to this hook. For instance, if the hook was actually defined inside
the constructor function.

This commit fixes that but also fixes the fact that the initial call was
being made in the postDigest anyway, which was incorrect because the
it should have been made before the `$onInit` call.
petebacondarwin added a commit that referenced this pull request Apr 1, 2016
Due to the way that we instantiate controllers, the `$onChanges` hook
was not always available at the time we were trying to trigger the initial
call to this hook. For instance, if the hook was actually defined inside
the constructor function.

This commit fixes that but also fixes the fact that the initial call was
being made in the postDigest anyway, which was incorrect because the
it should have been made before the `$onInit` call.

Closes #14355
Closes #14359
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants