phoenixframework / phoenix_html

Building blocks for working with HTML in Phoenix

Repository from Github https://github.comphoenixframework/phoenix_htmlRepository from Github https://github.comphoenixframework/phoenix_html

Undocumented behavior change of data-attrs with nil values.

eldano opened this issue · comments

When passing nil values to data-attributes the behavior changed in phoenix_html 3.3.0. It used to render an empty data-attr, but now the attr is not rendered.
Example:

<%= content_tag :h1, "title", data: [title: nil] %>

renders in phoenix_html 3.2.0:
<h1 data-title>title</h1>

renders in phoenix_html 3.3.0:
<h1>title</h1>

Not sure if it's a bug or intended to have a consistent behavior with Heex when using nil values, but it could be documented as a change in the changelog.
Users can fix this by passing true instead of nil for an empty data-attr.

Ya, i forgot to mention nil in the changelog (i mentioned true and false).