Skip to content

Commit 0f14029

Browse files
fix(transition): when redirecting, do not migrate $stateParams or $transition$ resolve values
1 parent ba029f6 commit 0f14029

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/common/common.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,8 +253,8 @@ export function pluck(collection, propName): any {
253253
* - array: only the elements which passed the callback predicate
254254
* - object: only the properties that passed the callback predicate
255255
*/
256-
export function filter<T>(collection: T[], callback: Predicate<T>): T[];
257-
export function filter<T>(collection: TypedMap<T>, callback: Predicate<T>): TypedMap<T>;
256+
export function filter<T>(collection: T[], callback: (T, key?) => boolean): T[];
257+
export function filter<T>(collection: TypedMap<T>, callback: (T, key?) => boolean): TypedMap<T>;
258258
export function filter<T>(collection: T, callback: Function): T {
259259
let arr = isArray(collection), result: any = arr ? [] : {};
260260
let accept = arr ? x => result.push(x) : (x, key) => result[key] = x;

src/path/node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export default class Node {
4747
}
4848

4949
/**
50-
* Returns a new path which is a subpath of this path. The new path starts from root and contains any nodes
51-
* that match the nodes in the second path. Nodes are compared using their state properties.
50+
* Returns a new path which is a subpath of the first path. The new path starts from root and contains any nodes
51+
* that match the nodes in the second path. Nodes are compared using their state property.
5252
* @param first {Node[]}
5353
* @param second {Node[]}
5454
* @returns {Node[]}

src/transition/transition.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import Param from "../params/param";
2222
import {ViewConfig} from "../view/view";
2323

2424
import {
25-
map, find, extend, mergeR, flatten, unnest, tail, forEach, identity,
25+
map, find, extend, filter, mergeR, flatten, unnest, tail, forEach, identity,
2626
omit, isObject, not, prop, propEq, toJson, val, abstractKey, arrayTuples, allTrueR
2727
} from "../common/common";
2828

@@ -251,8 +251,9 @@ export class Transition implements IHookRegistry {
251251
// add those resolvables to the redirected transition. Allows you to define a resolve at a parent level, wait for
252252
// the resolve, then redirect to a child state based on the result, and not have to re-fetch the resolve.
253253
let redirectedPath = this.treeChanges().to;
254-
let matching = Node.matching(redirectTo.treeChanges().to, redirectedPath);
255-
matching.forEach((node, idx) => node.resolves = redirectedPath[idx].resolves);
254+
let matching: Node[] = Node.matching(redirectTo.treeChanges().to, redirectedPath);
255+
const includeResolve = (resolve, key) => ['$stateParams', '$transition$'].indexOf(key) === -1;
256+
matching.forEach((node, idx) => extend(node.resolves, filter(redirectedPath[idx].resolves, includeResolve)));
256257

257258
return redirectTo;
258259
}

0 commit comments

Comments
 (0)