Taritsyn/WebMarkupMin

Encoding in HtmlAttributeValueHelpers breaks Third Party JS

mclausing opened this issue · 1 comments

I'm using a third party .net/js library which sticks json in to a data- attribute on a div and then uses it to hydrate. The HtmlAttributeValueHelpers.Encode method seems to break the Javascript. I'm not positive which character replacement causes it, but my guess is ". It would be great to either have a setting to disable/enable this, or allow for some dependency injection with our own service, or have a way to ignore certain fields.

As it stands there is no easy way to do this, and I worked around it by disabling for my path/request.

Hello, Michael!

I'm using a third party .net/js library which sticks json in to a data- attribute on a div and then uses it to hydrate. The HtmlAttributeValueHelpers.Encode method seems to break the Javascript.

Could you give a specific example: name of .NET/JS library, error message, HTML code before and after minification.

I'm not positive which character replacement causes it, but my guess is ".

It might make sense for you to experiment with the AttributeQuotesStyle setting (see the “HTML Minifier” section documentation). You can use the WebMarkupMin Online site to experiment with HTML code.

For now, as a temporary solution, you can wrap this div in a ignoring comment tag.