diff options
| author | Pavel Vasek | 2013-05-24 18:23:55 +0200 | 
|---|---|---|
| committer | Igor Minar | 2013-07-24 10:38:13 -0700 | 
| commit | dca23173e25a32cb740245ca7f7b01a84805f43f (patch) | |
| tree | b887697b1b5c656c8426b7e82b2d965b807e4679 /src/ng/browser.js | |
| parent | 0a3ec5f8bbc1b51c9188f661df1697cc6a32c6a5 (diff) | |
| download | angular.js-dca23173e25a32cb740245ca7f7b01a84805f43f.tar.bz2 | |
fix($location): prevent infinite digest error due to IE bug
If an app uses HTML5 mode and we open an html5 url on IE8 or 9 which
don't support location href, we use location.replace to reload the page
with the hashbang equivalent of the url but this fails with infinite
digest. This is because location.replace doesn't update location.href
synchronously on IE8 and 9.
Closes #2802, #3305, #1417
Diffstat (limited to 'src/ng/browser.js')
| -rw-r--r-- | src/ng/browser.js | 18 | 
1 files changed, 13 insertions, 5 deletions
| diff --git a/src/ng/browser.js b/src/ng/browser.js index f1f80bdf..8d6fa80b 100644 --- a/src/ng/browser.js +++ b/src/ng/browser.js @@ -124,7 +124,8 @@ function Browser(window, document, $log, $sniffer) {    //////////////////////////////////////////////////////////////    var lastBrowserUrl = location.href, -      baseElement = document.find('base'); +      baseElement = document.find('base'), +      replacedUrl = null;    /**     * @name ng.$browser#url @@ -159,14 +160,21 @@ function Browser(window, document, $log, $sniffer) {            baseElement.attr('href', baseElement.attr('href'));          }        } else { -        if (replace) location.replace(url); -        else location.href = url; +        if (replace) { +          location.replace(url); +          replacedUrl = url; +        } else { +          location.href = url; +          replacedUrl = null; +        }        }        return self;      // getter      } else { -      // the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172 -      return location.href.replace(/%27/g,"'"); +      // - the replacedUrl is a workaround for an IE8-9 issue with location.replace method that doesn't update +      //   location.href synchronously +      // - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172 +      return replacedUrl || location.href.replace(/%27/g,"'");      }    }; | 
