MCPcopy Index your code
hub / github.com/ampproject/amphtml / dereferenceArgsVariables

Function dereferenceArgsVariables

src/service/action-impl.js:1132–1163  ·  view source on GitHub ↗
(args, event, opt_args)

Source from the content-addressed store, hash-verified

1130 * @private
1131 */
1132export function dereferenceArgsVariables(args, event, opt_args) {
1133 if (!args) {
1134 return args;
1135 }
1136 const data = opt_args || {};
1137 if (event) {
1138 const detail = getDetail(/** @type {!Event} */ (event));
1139 if (detail) {
1140 data['event'] = detail;
1141 }
1142 }
1143 const applied = map();
1144 Object.keys(args).forEach((key) => {
1145 let value = args[key];
1146 // Only JSON expression strings that contain dereferences (e.g. `foo.bar`)
1147 // are processed as ActionInfoArgExpressionDef. We also support
1148 // dereferencing strings like `foo` iff there is a corresponding key in
1149 // `data`. Otherwise, `foo` is treated as a string "foo".
1150 if (typeof value == 'object' && value.expression) {
1151 const expr = /** @type {ActionInfoArgExpressionDef} */ (value).expression;
1152 const exprValue = getValueForExpr(data, expr);
1153 // If expr can't be found in data, use null instead of undefined.
1154 value = exprValue === undefined ? null : exprValue;
1155 }
1156 if (data[value]) {
1157 applied[key] = data[value];
1158 } else {
1159 applied[key] = value;
1160 }
1161 });
1162 return applied;
1163}
1164
1165/**
1166 * @param {string} s

Callers 2

test-action.jsFile · 0.90
action_Method · 0.85

Calls 4

getDetailFunction · 0.90
mapFunction · 0.90
getValueForExprFunction · 0.90
forEachMethod · 0.45

Tested by

no test coverage detected