Permit holding custom data in options #130
Open
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.
When using the
<:option>slot, it is convenient to be able to store other data in the options solely for customising the rendering of an option. E.g.:However, all fields in an option currently need to support encoding to JSON since the list of selected options is sent to the client. Thus, only custom data fields which support encoding to JSON can be included in the options.
This commit changes that by cleansing the set of selected options before sending them to the client: any fields other than
:label:value:disabled:tag_labelare omitted, the first three seem to be the 'canonical set' which the
normalize_option/1function returns,:tag_labelis a supported optional field.That way, whatever custom data is stored on options for customising the rendering is not sent to the client - and does not require defining a protocol implementation for e.g.
Jason.Encodereither.