Open
Description
We currently require our consumers to coerce and validate their attributes themselves within their converter callbacks.
It may be beneficial to coerce the type of each XML node attribute value for use within a converter callback.
e.g.,
<Party>
<Person name="Mary" age="20" ready="true" />
</Party>
const xmlToReact = new XMLToReact({ Person: convertPerson });
function convertPerson (attributes) {
typeof attributes.name; // 'string'
typeof attributes.age; // 'string'
typeof attributes.ready; // 'string'
return { type: 'div', props: attributes };
}
The value of each XML node attribute is a string.
If we coerce each the type of each value, we would instead the following:
function convertPerson (attributes) {
typeof attributes.name; // 'string'
typeof attributes.age; // 'number'
typeof attributes.ready; // 'boolean'
return { type: 'div', props: attributes };
}
for boolean attributes, we should consider HTML's approach
related: #16 (comment)