NUglify icon indicating copy to clipboard operation
NUglify copied to clipboard

Minification strips attribute value of `hx-boost=true` to just `hx-boost`, breaking functionality

Open helpimnotdrowning opened this issue 6 months ago • 3 comments

Are you using the latest verion of NUglify, especially if used through BunderMinifier? Update before raising a bug as your issue is probably already fixed.

I am using NUglify 1.21.15 through PSParseHTML (HtmlTinkerX)

Describe the bug The HTMX library features an element attribute hx-boost. This attribute must have a value of either "true" or "false" to function properly; blank values are effectively "false" and disable the expected functionality of the attribute.

To Reproduce First, install PSParseHTML with

Install-Module -Name PSParseHTML

Now, using Optimize-HTML, run the following command:

"<a hx-boost=true >" | Optimize-HTML

This should output

<a hx-boost=true></a>

Excepted output code The following incorrect HTML is emitted instead, breaking the expected functionality of the library:

<a hx-boost></a>

helpimnotdrowning avatar Oct 03 '25 02:10 helpimnotdrowning

similar: https://github.com/trullock/NUglify/issues/230

helpimnotdrowning avatar Oct 03 '25 02:10 helpimnotdrowning

This seems to be the intended purpose of HtmlSettings.ShortBooleanAttribute. I didn't scroll down far enough in the HtmlSettings.cs file!

helpimnotdrowning avatar Oct 03 '25 02:10 helpimnotdrowning

This is an easy fix, theres a list of excluded attributes in the html minifier

Send a PR

trullock avatar Oct 06 '25 13:10 trullock