asyncLiz / minify-html-literals

Minify HTML template literal strings
MIT License
68 stars 14 forks source link

Don't add attr quotes by default.. err at least not in a buggy way #42

Closed valpackett closed 2 years ago

valpackett commented 2 years ago

This is kinda the inverse of #12 :)

I've been wondering why certain event handlers were completely absent in the production build of my app…

Turns out

            html`
                <input type="text" .value=${propval} @change=${e =>
                    this._modify(draft => draft.properties[propname][idx] = e.target.value)
                }/>
            `

was being minified into

Be`<input type="text" .value="${r}" @change="${e=>this._modify((r=>r.properties[t][o]=e.target.value))}/">`

Look at that slash — it was consumed into the quoted string!

asyncLiz commented 2 years ago

The quotes are added by html-minifier because it sees @change=${...}/ and it believes the trailing slash is part of the attribute. So options to fix this: