activeadmin / arbre

An Object Oriented DOM Tree in Ruby
MIT License
756 stars 74 forks source link

Include blank attributes in HTML output #517

Closed javierjulio closed 12 months ago

javierjulio commented 12 months ago

This is mostly a full revert of commit 15267891a4c741154c7ee601d86851b16516588a which was a bad change. Empty attributes are valid HTML (e.g. boolean attributes) and should be supported here. The bad commit was for just addressing the class attribute but that applied to any attribute in HTML when it shouldn't have, even for just class.

With this change, the generated HTML string is improved:

tag = Arbre::HTML::Tag.new
tag.build disabled: nil, required: "", class: "blue"
tag.to_s
=> "<tag disabled required=\"\" class=\"blue\"></tag>\n"

Prior to this change, the output for that would have been:

=> "<tag class=\"blue\"></tag>\n"

This PR and #516 will be in a major (v2) release due to possible breaking change.

codecov[bot] commented 12 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.05 :warning:

Comparison is base (186106d) 92.56% compared to head (14d8ae9) 92.52%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #517 +/- ## ========================================== - Coverage 92.56% 92.52% -0.05% ========================================== Files 17 17 Lines 471 468 -3 ========================================== - Hits 436 433 -3 Misses 35 35 ``` | [Impacted Files](https://app.codecov.io/gh/activeadmin/arbre/pull/517?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=activeadmin) | Coverage Δ | | |---|---|---| | [lib/arbre/html/attributes.rb](https://app.codecov.io/gh/activeadmin/arbre/pull/517?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=activeadmin#diff-bGliL2FyYnJlL2h0bWwvYXR0cmlidXRlcy5yYg==) | `100.00% <100.00%> (ø)` | | | [lib/arbre/html/tag.rb](https://app.codecov.io/gh/activeadmin/arbre/pull/517?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=activeadmin#diff-bGliL2FyYnJlL2h0bWwvdGFnLnJi) | `93.68% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.