enketo-core icon indicating copy to clipboard operation
enketo-core copied to clipboard

Fix: setgeopoint actions correctly identify their affected nodeset

Open eyelidlessness opened this issue 2 years ago • 0 comments

Current behavior:

  1. Actions defined in the model, or in the body adjacent its input, populate the model correctly.
  2. Actions nested within their input, with an explicit ref attribute, fail to update the view. This is because there is a hidden HTML input representing the action (distinct from the input representing the model value), which the current behavior selects.
  3. Actions nested within their input, without an explicit ref attribute, replace the entire descendant tree of the model with the geopoint value. The cause is identical to the explicit-ref case, but the erroneously selected input has no name attribute. This causes the model update, in Nodeset.setVal, to evaluate against a nodeset resolving to the root data node.

A couple open questions:

  1. Should the third case described above ever be allowed to happen? My instinct is that we should never allow calling setVal on a node with children.

  2. How does this affect performance? It's definitely doing more work. It seems fine on my obviously small test form, but I'm not sure how much it'll impact larger or more complex forms.

eyelidlessness avatar Jun 07 '22 22:06 eyelidlessness