Skip to content

Commit 19715d1

Browse files
fix($state): fix $state.includes/.is to apply param types before comparisions
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
1 parent 9b3d9f6 commit 19715d1

File tree

2 files changed

+8
-22
lines changed

2 files changed

+8
-22
lines changed

Diff for: src/state.js

+6-16
Original file line numberDiff line numberDiff line change
@@ -1171,15 +1171,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
11711171
options = extend({ relative: $state.$current }, options || {});
11721172
var state = findState(stateOrName, options.relative);
11731173

1174-
if (!isDefined(state)) {
1175-
return undefined;
1176-
}
1177-
1178-
if ($state.$current !== state) {
1179-
return false;
1180-
}
1181-
1182-
return isDefined(params) && params !== null ? angular.equals($stateParams, params) : true;
1174+
if (!isDefined(state)) { return undefined; }
1175+
if ($state.$current !== state) { return false; }
1176+
return params ? equalForKeys(state.params.$$values(params), $stateParams) : true;
11831177
};
11841178

11851179
/**
@@ -1243,13 +1237,9 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
12431237
}
12441238

12451239
var state = findState(stateOrName, options.relative);
1246-
if (!isDefined(state)) {
1247-
return undefined;
1248-
}
1249-
if (!isDefined($state.$current.includes[state.name])) {
1250-
return false;
1251-
}
1252-
return equalForKeys(params, $stateParams);
1240+
if (!isDefined(state)) { return undefined; }
1241+
if (!isDefined($state.$current.includes[state.name])) { return false; }
1242+
return params ? equalForKeys(state.params.$$values(params), $stateParams, objectKeys(params)) : true;
12531243
};
12541244

12551245

Diff for: src/stateDirectives.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,11 @@ function $StateRefActiveDirective($state, $stateParams, $interpolate) {
253253

254254
function isMatch() {
255255
if (typeof $attrs.uiSrefActiveEq !== 'undefined') {
256-
return $state.$current.self === state && matchesParams();
256+
return state && $state.is(state.name, params);
257257
} else {
258-
return state && $state.includes(state.name) && matchesParams();
258+
return state && $state.includes(state.name, params);
259259
}
260260
}
261-
262-
function matchesParams() {
263-
return !params || equalForKeys(params, $stateParams);
264-
}
265261
}]
266262
};
267263
}

0 commit comments

Comments
 (0)