evaluateElementProps function
ElementNode
evaluateElementProps(
- ElementNode el,
- EvaluationContext ctx,
- IsReactiveProp reactive,
- List<
OpenUiError> errors,
lang-core evaluateElementProps: evaluates each prop, reporting a failure to errors instead of throwing.
Implementation
ElementNode evaluateElementProps(
ElementNode el,
EvaluationContext ctx,
IsReactiveProp reactive,
List<OpenUiError> errors,
) {
if (!el.hasDynamicProps) return el;
var key = '';
void report(String message) => errors.add(
OpenUiError(
source: OpenUiErrorSource.runtime,
code: OpenUiErrorCode.runtimeError,
component: el.typeName,
statementId: el.statementId,
message: 'Evaluating prop "$key" on ${el.typeName} failed: $message',
hint: 'Check the expression used for prop "$key"',
),
);
final propCtx = ctx.copyWith(reportError: report);
final out = <String, Object?>{};
for (final MapEntry(key: prop, :value) in el.props.entries) {
key = prop;
try {
out[prop] = evaluateProp(
value,
propCtx,
reactive,
reactive(el.typeName, prop),
recurseElement: (child) =>
evaluateElementProps(child, propCtx, reactive, errors),
);
} on NodeLimitExceeded {
rethrow;
} catch (e) {
// lang-core keeps the raw value; Dart props never hold syntax, so it reads as null.
out[prop] = null;
report(errorMessage(e));
}
}
return el.withProps(out);
}