UNPKG

1.66 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.StateParams = void 0;
4var common_1 = require("../common/common");
5var StateParams = /** @class */ (function () {
6 function StateParams(params) {
7 if (params === void 0) { params = {}; }
8 common_1.extend(this, params);
9 }
10 /**
11 * Merges a set of parameters with all parameters inherited between the common parents of the
12 * current state and a given destination state.
13 *
14 * @param {Object} newParams The set of parameters which will be composited with inherited params.
15 * @param {Object} $current Internal definition of object representing the current state.
16 * @param {Object} $to Internal definition of object representing state to transition to.
17 */
18 StateParams.prototype.$inherit = function (newParams, $current, $to) {
19 var parentParams;
20 var parents = common_1.ancestors($current, $to), inherited = {}, inheritList = [];
21 for (var i in parents) {
22 if (!parents[i] || !parents[i].params)
23 continue;
24 parentParams = Object.keys(parents[i].params);
25 if (!parentParams.length)
26 continue;
27 for (var j in parentParams) {
28 if (inheritList.indexOf(parentParams[j]) >= 0)
29 continue;
30 inheritList.push(parentParams[j]);
31 inherited[parentParams[j]] = this[parentParams[j]];
32 }
33 }
34 return common_1.extend({}, inherited, newParams);
35 };
36 return StateParams;
37}());
38exports.StateParams = StateParams;
39//# sourceMappingURL=stateParams.js.map
\No newline at end of file