choojs / choojs/hyperx

undefined attribute values are converted to strings

Open
#27 5 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1k
Forks
45
PR merge metrics
No merged PRs in 30d

Description

When attribute values are `undefined` or `null` they are appended as strings 'undefined' or 'null'.

For example this code:

``` javascript
var none // unassigned
hx`...`
```

Will result in html like this:

``` html

  • ...

  • ```

    Whereas `virtual-hyperscript` will ignore the value and not add it to the class list.

    I'm not sure if this is the correct behavior, but i expected it to do the same as `virtual-hyperscript`. This can be achieved by the developer by supplying a custom concat function, or by ensuring that undefined values are never used, but i think this should be handled by default?

    If it is a bug, I think it can be fixed in the [concat function](https://github.com/substack/hyperx/blob/2.0.4/index.js#L13), by making undefined parameters default to empty strings (''). However maybe there is a better way to do it?

    Contributor guide

    No contributing guide indexed for this repository

    Assessment

    This issue has not been assessed yet.

    Get new issues in your inbox

    A short digest of beginner-friendly GitHub issues.