8000 bug #42249 [WebProfilerBundle] Use multi line comment (Nyholm) · symfony/symfony@f5bc4a1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f5bc4a1

Browse files
committed
bug #42249 [WebProfilerBundle] Use multi line comment (Nyholm)
This PR was merged into the 5.4 branch. Discussion ---------- [WebProfilerBundle] Use multi line comment | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #42248 | License | MIT | Doc PR | Since the css/js is "fake minified" (we just remove the new line character) we cannot use `//`. See comment in the head of `base_js.html.twig`: ``` {# Caution: the contents of this file are processed by Twig before loading them as JavaScript source code. Always use '/*' comments instead of '//' comments to avoid impossible-to-debug side-effects #} ``` I also added a small test to enforce this. Commits ------- f7d516e [WebProfilerBundle] Use multi line comment
2 parents babdf51 + f7d516e commit f5bc4a1

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/base_js.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
748748
return;
749749
}
750750
751-
// hide rows that don't match the current filters
751+
/* hide rows that don't match the current filters */
752752
let numVisibleRows = 0;
753753
logs.querySelectorAll('tbody tr').forEach((row) => {
754754
if ('all' !== selectedType && selectedType !== row.getAttribute('data-type')) {
@@ -773,11 +773,11 @@ if (typeof Sfjs === 'undefined' || typeof Sfjs.loadToolbar === 'undefined') {
773773
document.querySelector('table.logs').style.display = 0 === numVisibleRows ? 'none' : 'table';
774774
document.querySelector('.no-logs-message').style.display = 0 === numVisibleRows ? 'block' : 'none';
775775
776-
// update the selected totals of all filters
776+
/* update the selected totals of all filters */
777777
document.querySelector('#log-filter-priority .filter-active-num').innerText = (priorities.length === selectedPriorities.length) ? 'All' : selectedPriorities.length;
778778
document.querySelector('#log-filter-channel .filter-active-num').innerText = (channels.length === selectedChannels.length) ? 'All' : selectedChannels.length;
779779
780-
// update the currently selected "log type" tab
780+
/* update the currently selected "log type" tab */
781781
document.querySelectorAll('#log-filter-type li').forEach((tab) => tab.classList.remove('active'));
782782
document.querySelector(`#log-filter-type input[value="${selectedType}"]`).parentElement.classList.add('active');
783783
},
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\WebProfilerBundle\Tests\Resources;
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Make sure we can minify content in toolbar.
18+
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
19+
*/
20+
class MinifyTest extends TestCase
21+
{
22+
public function testNoSingleLineComments()
23+
{
24+
$dir = dirname(__DIR__, 2).'/Resources/views/Profiler';
25+
$message = 'There cannot be any single line comment in this file. Consider using multiple line comment. ';
26+
$this->assertTrue(2 === substr_count(file_get_contents($dir . '/base_js.html.twig'), '//'), $message);
27+
$this->assertTrue(0 === substr_count(file_get_contents($dir.'/toolbar.css.twig'), '//'), $message);
28+
}
29+
}

0 commit comments

Comments
 (0)
0