diff --git a/src/common.js b/src/common.js index bd2b97a5e..1dc0172ee 100644 --- a/src/common.js +++ b/src/common.js @@ -49,7 +49,7 @@ function ancestors(first, second) { * @param {Object} object A JavaScript object. * @return {Array} Returns the keys of the object as an array. */ -function keys(object) { +function objectKeys(object) { if (Object.keys) { return Object.keys(object); } @@ -97,7 +97,7 @@ function inheritParams(currentParams, newParams, $current, $to) { for (var i in parents) { if (!parents[i].params) continue; - parentParams = keys(parents[i].params); + parentParams = objectKeys(parents[i].params); if (!parentParams.length) continue; for (var j in parentParams) { diff --git a/src/state.js b/src/state.js index 88d066824..cf32681e3 100644 --- a/src/state.js +++ b/src/state.js @@ -91,7 +91,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { state.params = state.params || {}; if (!state.parent) { - return keys(state.params); + return objectKeys(state.params); } var paramNames = {}; forEach(state.params, function (v, k) { paramNames[k] = true; }); @@ -811,7 +811,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { } // Filter parameters before we pass them to event handlers etc. - toParams = filterByKeys(keys(to.params), toParams || {}); + toParams = filterByKeys(objectKeys(to.params), toParams || {}); // Broadcast start event and cancel the transition if requested if (options.notify) { @@ -1086,7 +1086,12 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { * @returns {string} compiled state url */ $state.href = function href(stateOrName, params, options) { - options = extend({ lossy: true, inherit: false, absolute: false, relative: $state.$current }, options || {}); + options = extend({ + lossy: true, + inherit: false, + absolute: false, + relative: $state.$current + }, options || {}); var state = findState(stateOrName, options.relative); @@ -1098,7 +1103,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { if (!nav || !nav.url) { return null; } - return $urlRouter.href(nav.url, filterByKeys(keys(state.params), params || {}), { absolute: options.absolute }); + return $urlRouter.href(nav.url, filterByKeys(objectKeys(state.params), params || {}), { + absolute: options.absolute + }); }; /** @@ -1128,7 +1135,7 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) { // necessary. In addition to being available to the controller and onEnter/onExit callbacks, // we also need $stateParams to be available for any $injector calls we make during the // dependency resolution process. - var $stateParams = (paramsAreFiltered) ? params : filterByKeys(keys(state.params), params); + var $stateParams = (paramsAreFiltered) ? params : filterByKeys(objectKeys(state.params), params); var locals = { $stateParams: $stateParams }; // Resolve 'global' dependencies for the state, i.e. those not specific to a view. diff --git a/src/urlMatcherFactory.js b/src/urlMatcherFactory.js index 04a21ea85..8d2607ead 100644 --- a/src/urlMatcherFactory.js +++ b/src/urlMatcherFactory.js @@ -239,7 +239,7 @@ UrlMatcher.prototype.exec = function (path, searchParams) { * pattern has no parameters, an empty array is returned. */ UrlMatcher.prototype.parameters = function (param) { - if (!isDefined(param)) return keys(this.params); + if (!isDefined(param)) return objectKeys(this.params); return this.params[param] || null; };