fix(common): update $locationShim to notify onChange listeners before… #32037
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
… emitting AngularJS events
The $locationShim has onChange listeners to allow for synchronization logic between
AngularJS and Angular. When the AngularJS routing events are emitted first, this can
cause Angular code to be out of sync. Notifying the listeners earlier solves the
problem.
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Listeners to the $locationShim onChange are notified after the $locationChangeSuccess or $locationChangeStart events.
Issue Number: N/A
What is the new behavior?
Listeners to the $locationShim onChange are notified immediately before the $locationChangeSuccess or $locationChangeStart events.
Does this PR introduce a breaking change?
If someone is already using this method and depending on the existing ordering of events then technically this could be breaking. But the contract for the onChange method doesn't make any guarentees about the ordering of these events, it just says that the listeners are notified.
Other information
See b/138246666 for more details on the Google internal bug causing this change.