-
Notifications
You must be signed in to change notification settings - Fork 51
Boolean attributes are not renderedΒ #77
Description
Consider this React component:
<video autoPlay />
The expected output when rendering is:
<video autoplay="" />
But Rapscallion actually returns
<video />
Note that the autoplay attribute is gone.
After quickly looking at the code, it seems like https://github.com/FormidableLabs/rapscallion/blob/master/src/render/attrs/index.js#L31 is responsible. If the value is true Object.keys(attrVal).length is indeed 0 but it is still a perfectly valid attribute. Checking if (attrVal === true) afterwards if then useless as it would have called continue previously, and the value is never inserted.
This is also illustrated by the failing test for attributes in the pull request #58 . If you look at the CI result here you will see many tests prop with no value failing for that reason.
I am not quite sure of the purpose of the Object.keys(attrVal).length check so I did not submit a pull request because I am unsure of the best way to fix it, but it should be an easy fix in any case.