htmlnano icon indicating copy to clipboard operation
htmlnano copied to clipboard

minifyJs turns single quotes in handler-attributes into double quotes

Open Kreozot opened this issue 7 years ago • 4 comments

Which is breaking code, of course. Here is the case: <a onclick="myFunc('my string')"> turning into <a onclick="myFunc("my string")">. When I disable minifyJs option, everything is fine.

Kreozot avatar Feb 22 '17 12:02 Kreozot

This might be fixable by simply specifying minifyJs: { quote_style: 1 }. I can't currently test, but writing this if someone else has some time.

fstanis avatar Jan 07 '19 01:01 fstanis

Sorry, @Kreozot, I still don't know how to fix that without adding too many hacks :-/

You could use the following config to fix your particular case:

minifyJs: {
    output: { quote_style: 1 },
},

I've added it to the documentation as well.

maltsev avatar Jan 22 '19 21:01 maltsev

And if someone is interested in fixing that bug I've added a failed test.

maltsev avatar Jan 22 '19 21:01 maltsev

@maltsev

The quote style is determined by posthtml-render's option.

It is possible for htmlnano to override terser's quote_style based on posthtml's option.

Update

I have opened a PR at posthtml-render:

https://github.com/posthtml/posthtml-render/pull/47

SukkaW avatar Nov 18 '20 03:11 SukkaW