wilsonzlin/minify-html

Minify break javascript

tcezard opened this issue · 1 comments

<!DOCTYPE html>
<html lang="EN">
<head>
    <meta charset="UTF-8">
    <title>Validation Report</title>
</head>
<body>


<script>
    let collapsibles = document.querySelectorAll('.collapsible');
    for (let collapsible of collapsibles) {
        collapsible.addEventListener('click', function() {
            this.classList.toggle('active');
            let content = this.nextElementSibling;
            if (content.style.display === 'block') {
                content.style.display = 'none';
            }
            else {
                content.style.display = 'block';
                content.scrollIntoView({block: 'nearest'});
            }
        });
    }
</script>
</body>
</html>

minified in python with version 0.15.0

import minify_html
minify_html.minify(html, minify_js=True, remove_processing_instructions=True)

That is minified to:

<!doctypehtml><html lang=EN><meta charset=UTF-8><title>Validation Report</title><body><script>let collapsibles=document.querySelectorAll(`.collapsible`);for(let a of collapsibles){a.addEventListener(`click`,function(){this.classList.toggle(`active`);let a=this.nextElementSibling;if(a.style.display===b){a.style.display=`none`}else{a.style.display=b;a.scrollIntoView({block:`nearest`})}})}</script>

Where the javascript variable names are muddled up and string block is converted to b.
It worked fine in 0.11.1 before.