Skip to content

Commit f65f5cf

Browse files
authored
Merge pull request #73 from WyriHaximus/dependabot/composer/voku/html-min-4.0.7
Bump voku/html-min from 4.0.6 to 4.0.7
2 parents 149e3c3 + 44b6108 commit f65f5cf

File tree

14 files changed

+327
-294
lines changed

14 files changed

+327
-294
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"require": {
1717
"php": "^7.2",
18-
"voku/html-min": "^4.0.4",
18+
"voku/html-min": "^4.0.7",
1919
"wyrihaximus/compress": "^1.1",
2020
"wyrihaximus/css-compress": "^1.0",
2121
"wyrihaximus/js-compress": "^1.0"

composer.lock

Lines changed: 287 additions & 279 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Pattern/LdJson.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public function compress(SimpleHtmlDomInterface $element): void
4949
return;
5050
}
5151

52-
$element->innerhtml = $compressedInnerHtml;
52+
$attributes = '';
53+
$elementAttributes = $element->getAllAttributes();
54+
if ($elementAttributes !== null) {
55+
/**
56+
* @var string $attributeName
57+
* @var string $attributeValue
58+
*/
59+
foreach ($elementAttributes as $attributeName => $attributeValue) {
60+
$attributes .= $attributeName . '="' . $attributeValue . '"';
61+
}
62+
}
63+
64+
$element->outerhtml = '<script ' . $attributes . '>' . $compressedInnerHtml . '</script>';
5365
}
5466
}

src/Pattern/Style.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ public function compress(SimpleHtmlDomInterface $element): void
4141
return;
4242
}
4343

44-
$element->innerhtml = $compressedInnerHtml;
44+
$attributes = '';
45+
$elementAttributes = $element->getAllAttributes();
46+
if ($elementAttributes !== null) {
47+
/**
48+
* @var string $attributeName
49+
* @var string $attributeValue
50+
*/
51+
foreach ($elementAttributes as $attributeName => $attributeValue) {
52+
$attributes .= $attributeName . '="' . $attributeValue . '"';
53+
}
54+
}
55+
56+
$element->outerhtml = '<style ' . $attributes . '>' . $compressedInnerHtml . '</style>';
4557
}
4658

4759
private function stripComments(string $contents): string

tests/Compressor/HtmlCompressorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function providerMultipleSpaces(): iterable
5858
];
5959
yield [
6060
"<html>\n <head> </head>\n <body>\n <p id=\"text\" class=\"foo\">\n foo\n </p> <br /> <ul > <li> <p class=\"foo\">lall</p> </li></ul>\n </body>\n </html>",
61-
'<html><head> <body><p class=foo id=text> foo </p> <br><ul><li><p class=foo>lall </ul>',
61+
'<html><head> <body><p class=foo id=text> foo </p> <br> <ul><li><p class=foo>lall </ul>',
6262
];
6363
}
6464

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots> <style>pre code{background-color:inherit}</style> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
1+
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots> <style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"http:\/\/domain.com"}},{"@type":"ListItem","position":2,"item":{"name":"Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/"}},{"@type":"ListItem","position":3,"item":{"name":"Sub Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/sub-category-name\/"}}]},{"@context":"https:\/\/schema.org\/","@graph":[{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-potiron\/","name":"Mijot\u00e9e de potiron","url":"http:\/\/domain.com\/product\/mijote-de-potiron\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/","name":"Mijot\u00e9e de haricot vert","url":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/","name":"Mijot\u00e9e de carotte","url":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/","name":"Mijot\u00e9e de petit pois","url":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/","name":"Mijot\u00e9e de patate douce","url":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/","name":"Mijot\u00e9e de brocoli","url":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/"}]}]}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
1+
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"https:\/\/schema.org\/","@graph":[{"@context":"https:\/\/schema.org\/","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"name":"Home","@id":"http:\/\/domain.com"}},{"@type":"ListItem","position":2,"item":{"name":"Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/"}},{"@type":"ListItem","position":3,"item":{"name":"Sub Category title","@id":"http:\/\/domain.com\/product-category\/category-name\/sub-category-name\/"}}]},{"@context":"https:\/\/schema.org\/","@graph":[{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-potiron\/","name":"Mijot\u00e9e de potiron","url":"http:\/\/domain.com\/product\/mijote-de-potiron\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/","name":"Mijot\u00e9e de haricot vert","url":"http:\/\/domain.com\/product\/mijote-de-haricot-vert-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/","name":"Mijot\u00e9e de carotte","url":"http:\/\/domain.com\/product\/mijote-de-carotte-2\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/","name":"Mijot\u00e9e de petit pois","url":"http:\/\/domain.com\/product\/mijote-de-petit-pois\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/","name":"Mijot\u00e9e de patate douce","url":"http:\/\/domain.com\/product\/mijote-de-patate-douce\/"},{"@type":"Product","@id":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/","name":"Mijot\u00e9e de brocoli","url":"http:\/\/domain.com\/product\/mijote-de-brocoli-2\/"}]}]}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>

tests/EdgeCases/ld-json/out.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots> <style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
1+
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>pre code{background-color:inherit}</style><script type=application/ld+json>{"@context":"http://schema.org/","@type":"Product","name":"Yoast SEO for WordPress","image":"https://cdn-images.yoast.com/uploads/2010/10/Yoast_SEO_WP_plugin_FB.png","description":"Yoast SEO is the most complete WordPress SEO plugin. It handles the technical optimization of your site & assists with optimizing your content.","brand":{"@type":"Thing","name":"Yoast"},"offers":{"@type":"Offer","priceCurrency":"USD","price":"69.00"}}</script> <body class=blog><header><nav></nav> </header> <script>window.jQuery||document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>')</script>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script async id=fake-async>window.addEventListener('DOMContentLoaded',function(){(function($){alert("Hello world!")})(jQuery)})</script> <script defer src="data:text/javascript;base64,YWxlcnQoJ0hlbGxvIHdvcmxkIScpOw=="></script>
1+
<script async id=fake-async>window.addEventListener('DOMContentLoaded',function(){(function($){alert("Hello world!")})(jQuery)})</script><script defer src="data:text/javascript;base64,YWxlcnQoJ0hlbGxvIHdvcmxkIScpOw=="></script>

tests/Factory/fastest/out.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots> <style>/** quick fix because bootstrap <pre> has a background-color. */
1+
<!DOCTYPE html><html><head><meta content="noindex, follow" name=robots><style>/** quick fix because bootstrap <pre> has a background-color. */
22
pre code { background-color: inherit; }</style> <body class=blog><header><nav></nav> </header> <script>window.jQuery || document.write('<script src="http://blog.wyrihaximus.net/components/jquery/jquery.min.js"><\/script>');
33
alert('hoi');</script>

0 commit comments

Comments
 (0)