Swaagie / minimize

Minimize HTML
MIT License
162 stars 18 forks source link

"empty: true" still strips out empty attributes on option tags #49

Closed canebat closed 9 years ago

canebat commented 9 years ago
<select>
    <option value="">Select something</option>
</select>

the options will change to <option>Select something</option> even if I set minifyHTML({empty: true}).

Shouldn't be left as <option value="">Select something</option>?

Swaagie commented 9 years ago

Just tested and it seems to work fine, in this specific case you probably need new Minimize({ empty: true, spare: true });. empty will make sure the value attribute is added , e.g. <option value> and spare will add "" making sure the value attribute keeps it empty value <option value="">. Having just empty: true might cause the browser to optimize the attribute away, cause normally value is not a boolean attribute.

To make sure this is not some edge case bug, what version of minimize are you working with and what browser are you working on?

canebat commented 9 years ago

Adding spare: true like you suggested worked for me.

I'm using chrome, minimize 1.4.1.

My html is actually using angularjs:

<select  ng-model="item">
    <option value="">Select something</option>
    <option ng-repeat="i in items" ng-selected ="item == i.name>{{ i.name }}<option>
</select>