Skip to content

Commit eaa2436

Browse files
fix(Transition): Transition.params() should reduce the values from each node
1 parent 7013035 commit eaa2436

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/common/common.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ export function merge(dst, ...objs: Object[]) {
187187
return dst;
188188
}
189189

190+
/** Reduce function that merges each element of the list into a single object, using angular.extend */
191+
export const mergeR = (memo, item) => extend(memo, item);
192+
190193
/**
191194
* Finds the common ancestor path between two states.
192195
*

src/common/trace.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ function normalizedCat(input: Category): string {
2626
return isNumber(input) ? Category[input] : Category[Category[input]];
2727
}
2828

29-
let format = pattern([
30-
[not(isDefined), val("undefined")],
31-
[isNull, val("null")],
32-
[isPromise, promiseToString],
33-
[is(Transition), invoke("toString")],
34-
[is(Resolvable), invoke("toString")],
35-
[isInjectable, functionToString],
36-
[val(true), identity]
37-
]);
38-
3929
function stringify(o) {
30+
let format = pattern([
31+
[not(isDefined), val("undefined")],
32+
[isNull, val("null")],
33+
[isPromise, promiseToString],
34+
[is(Transition), invoke("toString")],
35+
[is(Resolvable), invoke("toString")],
36+
[isInjectable, functionToString],
37+
[val(true), identity]
38+
]);
39+
4040
return JSON.stringify(o, (key, val) => format(val)).replace(/\\"/g, '"');
4141
}
4242

src/transition/transition.ts

Lines changed: 2 additions & 2 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, flatten, unnest, tail, forEach, identity,
25+
map, find, extend, mergeR, flatten, unnest, tail, forEach, identity,
2626
omit, isObject, not, prop, propEq, toJson, val, abstractKey
2727
} from "../common/common";
2828

@@ -145,7 +145,7 @@ export class Transition implements IHookRegistry {
145145
*/
146146
// TODO
147147
params(pathname: string = "to"): { [key: string]: any } {
148-
return tail(this._treeChanges[pathname]).values;
148+
return this._treeChanges[pathname].map(prop("values")).reduce(mergeR, {});
149149
}
150150

151151
/**

0 commit comments

Comments
 (0)