MCPcopy
hub / github.com/angular-ui/ui-router / Browser

Function Browser

test/angular/1.7/angular.js:6538–6843  ·  view source on GitHub ↗

* @param {object} window The global window object. * @param {object} document jQuery wrapped document. * @param {object} $log window.console or an object with the same interface. * @param {object} $sniffer $sniffer service

(window, document, $log, $sniffer, $$taskTrackerFactory)

Source from the content-addressed store, hash-verified

6536 * @param {object} $sniffer $sniffer service
6537 */
6538function Browser(window, document, $log, $sniffer, $$taskTrackerFactory) {
6539 var self = this,
6540 location = window.location,
6541 history = window.history,
6542 setTimeout = window.setTimeout,
6543 clearTimeout = window.clearTimeout,
6544 pendingDeferIds = {},
6545 taskTracker = $$taskTrackerFactory($log);
6546
6547 self.isMock = false;
6548
6549 //////////////////////////////////////////////////////////////
6550 // Task-tracking API
6551 //////////////////////////////////////////////////////////////
6552
6553 // TODO(vojta): remove this temporary api
6554 self.$$completeOutstandingRequest = taskTracker.completeTask;
6555 self.$$incOutstandingRequestCount = taskTracker.incTaskCount;
6556
6557 // TODO(vojta): prefix this method with $$ ?
6558 self.notifyWhenNoOutstandingRequests = taskTracker.notifyWhenNoPendingTasks;
6559
6560 //////////////////////////////////////////////////////////////
6561 // URL API
6562 //////////////////////////////////////////////////////////////
6563
6564 var cachedState, lastHistoryState,
6565 lastBrowserUrl = location.href,
6566 baseElement = document.find('base'),
6567 pendingLocation = null,
6568 getCurrentState = !$sniffer.history ? noop : function getCurrentState() {
6569 try {
6570 return history.state;
6571 } catch (e) {
6572 // MSIE can reportedly throw when there is no state (UNCONFIRMED).
6573 }
6574 };
6575
6576 cacheState();
6577
6578 /**
6579 * @name $browser#url
6580 *
6581 * @description
6582 * GETTER:
6583 * Without any argument, this method just returns current value of `location.href` (with a
6584 * trailing `#` stripped of if the hash is empty).
6585 *
6586 * SETTER:
6587 * With at least one argument, this method sets url to new value.
6588 * If html5 history api supported, `pushState`/`replaceState` is used, otherwise
6589 * `location.href`/`location.replace` is used.
6590 * Returns its own instance to allow chaining.
6591 *
6592 * NOTE: this api is intended for use only by the `$location` service. Please use the
6593 * {@link ng.$location $location service} to change url.
6594 *
6595 * @param {string} url New url (when used as setter)

Callers

nothing calls this directly

Calls 6

cacheStateFunction · 0.70
isUndefinedFunction · 0.70
urlResolveFunction · 0.70
stripHashFunction · 0.70
getHashFunction · 0.70
trimEmptyHashFunction · 0.70

Tested by

no test coverage detected