Closed nlemoine closed 5 years ago
Minification is breaking JSON placed in data-* attributes. Actually, it doesn't "break" the JSON part, it replaces single quotes with double quotes.
<div data-json='{"key":"value"}'></div>
Becomes:
<div data-json="{"key":"value"}"></div>
Unfortunalety, you can't use single quotes in JSON. But you can use single quotes in HTML.
<?php require_once 'vendor/autoload.php'; use voku\helper\HtmlMin; $htmlMin = new HtmlMin(); ob_start(); ?> <html> <body> <div data-json='{"key":"value"}'></div> </body> </html> <?php $html = ob_get_clean(); echo $htmlMin->minify($html);
I have no idea, I didn't dig into code.
Thanks for the good bug report. :+1: The issue is fixed in version 3.1.7.
What is this feature about (expected vs actual behaviour)?
Minification is breaking JSON placed in data-* attributes. Actually, it doesn't "break" the JSON part, it replaces single quotes with double quotes.
Becomes:
Unfortunalety, you can't use single quotes in JSON. But you can use single quotes in HTML.
How can I reproduce it?
Does it take minutes, hours or days to fix?
I have no idea, I didn't dig into code.