Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deserialize
""
to NaN
for Number
type.
It would always be counter-intuitive to declare `<my-element number>` in HTML markup and introspect the element to find `element.number === 0`. In other words, while it’s true that in JS `Number('') === 0`, this is not sensible behavior when deserializing values in markup into typed objects in JS. This is mostly due to the concept of so-called “boolean attributes”. As a custom element author, you don’t want to coerce a boolean attribute to a `Number`. In otherwords, when dealing with numbers, the markup `<my-element number>` should _not_ equal `<my-element number="0">`. While this change makes a strong opinion, part of the goal of `x-element` is to reduce obvious boiler plate. Since it seems incredibly unlikely that any author would actually _desire_ the `Number('') >> 0` behavior, taking a stance here seems more helpful than hurtful. Additionally, we will always, conceptually, have a _default_ deserializer. In the future, if needed, we could allow authors to declare their own deserializers / serializers within property declarations. Closes #147.
- Loading branch information