Skip to content

Commit 66dda2f

Browse files
authored
fix(view): zero-values in attributes (#1679)
1 parent 4f731ed commit 66dda2f

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/view/src/Elements/GenericElement.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function compile(): string
4141
$attributes = [];
4242

4343
foreach ($this->getAttributes() as $name => $value) {
44-
if ($value) {
44+
if ($value !== null && $value !== '') {
4545
$attributes[] = $name . '="' . $value . '"';
4646
} else {
4747
$attributes[] = $name;

tests/Integration/View/TempestViewRendererTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,4 +856,13 @@ public function test_attributes_with_single_quotes(): void
856856

857857
$this->assertSnippetsMatch('<div class="hello"></div>', $html);
858858
}
859+
860+
public function test_zero_in_attribute(): void
861+
{
862+
$html = $this->render(<<<'HTML'
863+
<table border="0"></table>
864+
HTML);
865+
866+
$this->assertSnippetsMatch('<table border="0"></table>', $html);
867+
}
859868
}

0 commit comments

Comments
 (0)