fix(web_core): resolve DynamicValues inside function arg arrays#2016
fix(web_core): resolve DynamicValues inside function arg arrays#2016kokoro-ele wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates DataContext to support element-wise resolution and reactive subscription of arrays containing DynamicValues, along with corresponding unit tests. The feedback suggests optimizing both resolveDynamicValue and resolveSignal by checking if an array is completely static before recursively processing its elements, which avoids unnecessary allocations and signal creation for static arrays.
|
@Varun-S10 Thanks for the review! Applied in 30ae9fb. I extracted the static check into a shared private helper (containsDynamicValue) used by both resolveDynamicValue and resolveSignal, rather than duplicating the inline closure in each method. Fully static arrays now return as-is (no re-allocation) in resolveDynamicValue, and become a single static signal in resolveSignal, skipping the per-element signals + computed. One trade-off worth noting: for arrays that do contain dynamic values, the pre-check adds an extra scan (and re-scans nested arrays during recursion). Since dynamic arrays in practice are small function args (e.g. and/or values) while static arrays can be large (e.g. dropdown options), optimizing the static path at this minor cost seemed like the right balance. Also added tests covering the no-reallocation fast path and nested dynamic elements. |
Address review feedback: add a containsDynamicValue fast-path check so static arrays are returned as-is in resolveDynamicValue and wrapped in a single signal in resolveSignal, avoiding N element signals + computed.
30ae9fb to
f9be169
Compare
Summary
Fixes
DataContext.resolveDynamicValue()andresolveSignal()treating arrays as primitive literals, which prevented DynamicValue elements inside arrays (e.g.,and/orvaluesarrays) from being resolved.Problem
When a function call like
and/orreceives an array-typed argument (values: [...]), any path bindings or nested function calls within that array were returned as-is without resolution. Theand/orfunctions received raw{path: "..."}or{call: "..."}objects (always truthy) instead of actual resolved values, causing validation logic to silently pass.Root Cause
The early-return guard in both
resolveDynamicValueandresolveSignalconflated arrays with primitives:Fix
Separate the array check from the primitive early-return and recursively resolve each element:
Same fix applied to
resolveSignalfor reactive resolution.Test Plan
Added unit tests covering:
and/orvalues)Closes #2015
🤖 Generated with Claude Code