voku / HtmlMin

:clamp: HtmlMin: HTML Compressor and Minifier via PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vue.js @shorthand attribute problem

andrewckor opened this issue · comments

Hello, I am using your script "voku/html-min": "^3.0" for some time and it is working great.
Recently we integrated vue.js into our laravel project and an unexpected bug appeared.
After some investigation I realised that the minifier removes the vue js attributes that start with @.

Let me show you an example. This code:
<select v-model="filter" @change="getGraphData" :class="['c-chart__label']" name="filter">

If you minify it through:

$htmlMin = new HtmlMin();
$htmlMin->doOptimizeViaHtmlDomParser(true);
$htmlMin->doRemoveWhitespaceAroundTags(true);
$htmlMin->doRemoveSpacesBetweenTags(true); 

return $htmlMin->minify($content);

You get this in the frontend:
<select v-model="filter" :class="['c-chart__label']" name="filter">

That means that HtmlMin it strips out attributes that start with @.
It shouldn't be a hard fix for you @voku.

Thanks.

Thanks for the bug report. Fixed in version 3.0.3.

The problem is the PHP-Dom-Parser (DOMDocument), it can't handle the "@" in front of an attribute, so here is the hack for that... ;) voku/simple_html_dom@2e18d6b

Thank you very much for your quick response. 👍

Hey @voku I updated to simple_html_dom 4.1.4 and html-min 3.0.3 and now this is what I get to the final html with the same settings:

<select v-model="filter" ____simple_html_dom__voku__at____change="getGraphData" :class="['c-chart__label']" name="filter">