Skip to content

Commit

Permalink
chore(common): unique name for internal function
Browse files Browse the repository at this point in the history
  • Loading branch information
nateabele committed Apr 17, 2014
1 parent 91f75ae commit b881c72
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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) {
Expand Down
17 changes: 12 additions & 5 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -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; });

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand All @@ -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
});
};

/**
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/urlMatcherFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit b881c72

Please sign in to comment.