Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Parser/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ public function getStaticValue(): mixed
throw new \LogicException("Cannot get static value of dynamic attribute '{$this->name}'.");
}

if ($this->valueless) {
return true;
}

if (! $this->bound()) {
return $this->value;
}

return match ($this->value) {
'true' => true,
'false' => false,
Expand Down
9 changes: 8 additions & 1 deletion tests/ComparisonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
['readonly' => false],
));

test('foldable literal string attributes matching PHP constants', fn () => compare(<<<'BLADE'
<x-foldable.input value="true" />
<x-foldable.input value="false" />
<x-foldable.input value="null" />
BLADE
));

test('same component in a slot doesnt affect parents attributes', fn () => compare(<<<'BLADE'
<x-card>
<x-card x-data>
Expand Down Expand Up @@ -115,4 +122,4 @@
</x-wrapper>
</x-card>
BLADE
));
));
Loading