Skip to content

Commit

Permalink
fix($state): fix $state.includes/.is to apply param types before comp…
Browse files Browse the repository at this point in the history
…arisions

fix(uiSref): made isMatch delegate to $state.is/.includes with params

- Made is/includes use state.params.$$values() to encode values before comparison.

Closes #1513
  • Loading branch information
christopherthielen committed Nov 17, 2014
1 parent 9b3d9f6 commit 19715d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
22 changes: 6 additions & 16 deletions src/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -1171,15 +1171,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
options = extend({ relative: $state.$current }, options || {});
var state = findState(stateOrName, options.relative);

if (!isDefined(state)) {
return undefined;
}

if ($state.$current !== state) {
return false;
}

return isDefined(params) && params !== null ? angular.equals($stateParams, params) : true;
if (!isDefined(state)) { return undefined; }
if ($state.$current !== state) { return false; }
return params ? equalForKeys(state.params.$$values(params), $stateParams) : true;
};

/**
Expand Down Expand Up @@ -1243,13 +1237,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
}

var state = findState(stateOrName, options.relative);
if (!isDefined(state)) {
return undefined;
}
if (!isDefined($state.$current.includes[state.name])) {
return false;
}
return equalForKeys(params, $stateParams);
if (!isDefined(state)) { return undefined; }
if (!isDefined($state.$current.includes[state.name])) { return false; }
return params ? equalForKeys(state.params.$$values(params), $stateParams, objectKeys(params)) : true;
};


Expand Down
8 changes: 2 additions & 6 deletions src/stateDirectives.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,11 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {

function isMatch() {
if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
return $state.$current.self === state && matchesParams();
return state && $state.is(state.name, params);
} else {
return state && $state.includes(state.name) && matchesParams();
return state && $state.includes(state.name, params);
}
}

function matchesParams() {
return !params || equalForKeys(params, $stateParams);
}
}]
};
}
Expand Down

0 comments on commit 19715d1

Please sign in to comment.