alex-kinokon / jsx-dom

Use JSX to create DOM elements.
BSD 3-Clause "New" or "Revised" License
277 stars 30 forks source link

Attribute with false value are rendered since 7.0.4 #65

Closed yoriiis closed 3 years ago

yoriiis commented 3 years ago

According to the JSX documentation and the README of the project, an attribute with the false value should be ignored.

Note that false, true, null, undefined will be ignored per React documentations, and everything else will be used.

Since the v7.0.4, the value of the boolean is rendered even if the value is false. The change was introduced by the following commit https://github.com/proteriax/jsx-dom/commit/10cb737020fc7bc7d3507f760e9e3821faef583.

Example:

<a href="" target={false}></a>
<a href="" target={false && '_blank'}></a>
<a href="" data-target={false}></a>
<a href="" data-target={false && '_blank'}></a>

Is rendered as:

<a href="" target="false"></a> /* incorrect */
<a href="" target="false"></a> /* incorrect */
<a href=""></a> /* correct */
<a href=""></a> /* correct */

It seems data-* attribute are ignored but not the target attribute.

Is it a mistake?

alex-kinokon commented 3 years ago

You’re right. This is a bug.

alex-kinokon commented 3 years ago

Published 8.0.0-beta.0 to revert to the old boolean behavior.