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

Fix infinite digest loop triggered by changing $location.path() #3951

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/ng/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ function Browser(window, document, $log, $sniffer) {

var lastBrowserUrl = location.href,
baseElement = document.find('base'),
replacedUrl = null;
replacedUrl = null,
ignoreHashChange = false;

/**
* @name ng.$browser#url
Expand Down Expand Up @@ -160,13 +161,16 @@ function Browser(window, document, $log, $sniffer) {
baseElement.attr('href', baseElement.attr('href'));
}
} else {
// Flag to ignore hashchange events occasionally generated in Android 2.2, 2.3
ignoreHashChange = true;
if (replace) {
location.replace(url);
replacedUrl = url;
} else {
location.href = url;
replacedUrl = null;
}
ignoreHashChange = false;
}
return self;
// getter
Expand All @@ -182,7 +186,7 @@ function Browser(window, document, $log, $sniffer) {
urlChangeInit = false;

function fireUrlChange() {
if (lastBrowserUrl == self.url()) return;
if (lastBrowserUrl == self.url() || ignoreHashChange) return;

lastBrowserUrl = self.url();
forEach(urlChangeListeners, function(listener) {
Expand Down