angular/angular.js — pull request #4896 by theRobinator (2013-11-11 23:58:46+00:00)
Title: fix ($location): Stop digest loops in $locationWatch by detecting duplicate URL transitions

The $locationWatch function will loop forever if it is called when $browser decides that no transition needs to be made, firing extra $locationChangeStart events until it hits the 10 digest iterations loop. This happens commonly in the case when the browser delays too long in updating location.href and additional $locationWatches are fired before location.href is updated.

(To see what I mean about location.href delays, try "location.href = '/whatever'; alert(location.href);" in the Chrome console)

This patch causes $locationWatch to return an unchanged count in the case when it has attempted to make the same transition twice in a row, thereby stopping the loop and allowing the browser to resolve.