Skip to content

Commit 809cfab

Browse files
committed
Remove space before self-close when auto-fixed
1 parent f274696 commit 809cfab

8 files changed

+10
-2
lines changed

Magento2/Sniffs/Html/HtmlClosingVoidTagsSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public function process(File $phpcsFile, $stackPtr): void
9696
if ($fix) {
9797
$token = $phpcsFile->getTokens()[$ptr];
9898
$original = $match[0];
99-
$replacement = str_replace('/>', '>', $original);
99+
$replacement = str_replace(' />', '>', $original);
100+
$replacement = str_replace('/>', '>', $replacement);
100101
$phpcsFile->fixer->replaceToken(
101102
$ptr,
102103
str_replace($original, $replacement, $token['content'])

Magento2/Sniffs/Html/HtmlSelfClosingTagsSniff.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public function process(File $phpcsFile, $stackPtr)
8383
if ($fix) {
8484
$token = $phpcsFile->getTokens()[$ptr];
8585
$original = $match[0];
86-
$replacement = str_replace('/>', '></' . $match[1] . '>', $original);
86+
$replacement = str_replace(' />', '></' . $match[1] . '>', $original);
87+
$replacement = str_replace('/>', '></' . $match[1] . '>', $replacement);
8788
$phpcsFile->fixer->replaceToken(
8889
$ptr,
8990
str_replace($original, $replacement, $token['content'])

Magento2/Tests/Html/HtmlClosingVoidTagsUnitTest.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
</video>
3131
<wbr/>
3232
<hr/>
33+
<hr style="color: red" />
3334
</body>
3435
</html>

Magento2/Tests/Html/HtmlClosingVoidTagsUnitTest.inc.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
</video>
3131
<wbr>
3232
<hr>
33+
<hr style="color: red">
3334
</body>
3435
</html>

Magento2/Tests/Html/HtmlClosingVoidTagsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public function getWarningList()
3838
29 => 1,
3939
31 => 1,
4040
32 => 1,
41+
33 => 1,
4142
];
4243
}
4344
}

Magento2/Tests/Html/HtmlSelfClosingTagsUnitTest.1.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
<translate/>
4141
<scope/>
4242
<span/>
43+
<span style="color: red" />
4344
</body>
4445
</html>

Magento2/Tests/Html/HtmlSelfClosingTagsUnitTest.1.inc.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@
4040
<translate></translate>
4141
<scope></scope>
4242
<span></span>
43+
<span style="color: red"></span>
4344
</body>
4445
</html>

Magento2/Tests/Html/HtmlSelfClosingTagsUnitTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function getErrorList()
2525
40 => 1,
2626
41 => 1,
2727
42 => 1,
28+
43 => 1,
2829
];
2930
}
3031

0 commit comments

Comments
 (0)