Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue.js @shorthand attribute problem #18

Closed
andrewckor opened this issue May 7, 2018 · 4 comments
Closed

Vue.js @shorthand attribute problem #18

andrewckor opened this issue May 7, 2018 · 4 comments
Labels

Comments

@andrewckor
Copy link

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.

@andrewckor
Copy link
Author

It probably needs a @ somewhere here:
https://github.com/voku/HtmlMin/blob/master/src/voku/helper/HtmlMin.php#L923-L930

@voku
Copy link
Owner

voku commented May 8, 2018

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

@voku voku closed this as completed May 8, 2018
@voku voku added the bug label May 8, 2018
@andrewckor
Copy link
Author

andrewckor commented May 8, 2018

Thank you very much for your quick response. 👍

@andrewckor
Copy link
Author

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">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants