Support self-closing setvalue without value #615
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#564 added support for
setvalue
with an empty literal value or an emptyString
as the attribute value forvalue
. However, it didn't add support for a self-closingsetvalue
tag without avalue
attribute which is whatpyxform
actually generates in the case of an emptycalculation
:<setvalue event="xforms-value-changed" ref="/data/malaria_age"/>
What has been done to verify that this works as intended?
Added test and verified that the generated XML matches the one generated by
pyxform
.Why is this the best possible solution? Were any other approaches considered?
This is such a small change that I don't think there really are alternatives. It gets the desired behavior -- if there isn't an explicit value for a
value
attribute or as a child, then we clear the target.How does this change affect users? Describe intentional changes to behavior and behavior that could have accidentally been affected by code changes. In other words, what are the regression risks?
This loosens the requirements for
setvalue
. It could possibly allow more form design mistakes through but I think that risk is acceptable.Do we need any specific form for testing your changes? If so, please attach one.
See test.
Does this change require updates to documentation? If so, please file an issue here and include the link below.
getodk/docs#1287