@@ -29,7 +29,8 @@ function Browser(window, document, $log, $sniffer) {
29
29
history = window . history ,
30
30
setTimeout = window . setTimeout ,
31
31
clearTimeout = window . clearTimeout ,
32
- pendingDeferIds = { } ;
32
+ pendingDeferIds = { } ,
33
+ urlChangedOutsideAngular = false ;
33
34
34
35
self . isMock = false ;
35
36
@@ -146,6 +147,7 @@ function Browser(window, document, $log, $sniffer) {
146
147
* @param {boolean= } replace Should new url replace current history record ?
147
148
*/
148
149
self . url = function ( url , replace ) {
150
+ var currentHref ;
149
151
// Android Browser BFCache causes location, history reference to become stale.
150
152
if ( location !== window . location ) location = window . location ;
151
153
if ( history !== window . history ) history = window . history ;
@@ -175,10 +177,41 @@ function Browser(window, document, $log, $sniffer) {
175
177
// - newLocation is a workaround for an IE7-9 issue with location.replace and location.href
176
178
// methods not updating location.href synchronously.
177
179
// - the replacement is a workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=407172
178
- return newLocation || location . href . replace ( / % 2 7 / g, "'" ) ;
180
+ if ( newLocation ) {
181
+ return newLocation ;
182
+ }
183
+ if ( lastBrowserUrl !== ( currentHref = location . href . replace ( / % 2 7 / g, "'" ) ) ) {
184
+ urlChangedOutsideAngular = true ;
185
+ }
186
+ return currentHref ;
179
187
}
180
188
} ;
181
189
190
+ /**
191
+ * @name $browser#urlChangedOutsideAngular
192
+ *
193
+ * @description
194
+ * GETTER:
195
+ * Without any argument, this method just returns current value of urlChangedOutsideAngular.
196
+ *
197
+ * SETTER:
198
+ * With at least one argument, this method sets urlChangedOutsideAngular to new value.
199
+ *
200
+ * NOTE: this api is intended for use only by the $location service inside of $locationWatch.
201
+ *
202
+ * @param {boolean } val New value to set as urlChangedOutsideAngular,
203
+ * typically used to reset value to false.
204
+ */
205
+ self . urlChangedOutsideAngular = function ( val ) {
206
+ if ( isDefined ( val ) ) {
207
+ urlChangedOutsideAngular = val ;
208
+ return self ;
209
+ }
210
+ else {
211
+ return urlChangedOutsideAngular ;
212
+ }
213
+ }
214
+
182
215
var urlChangeListeners = [ ] ,
183
216
urlChangeInit = false ;
184
217
0 commit comments