Skip to content

Commit 55c4b36

Browse files
committed
bug #261 [Twig][Live] null attribute values render without value (ie autofocus) (kbond)
This PR was merged into the 2.x branch. Discussion ---------- [Twig][Live] null attribute values render without value (ie autofocus) | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | Tickets | n/a | License | MIT Ref: symfony/ux#220 (comment) A null attribute value renders without the _value_: ```twig {# templates/components/my_component.html.twig #} <input{{ attributes}}/> {# render component #} {{ component('my_component', { type: 'text', value: '', autofocus: null }) }} {# renders as: #} <input type="text" value="" autofocus/> ``` **TODO:** - [x] `null` vs `''` (symfony/ux#220 (comment)) - [x] attributes without a value like `autofocus` (symfony/ux#220 (comment)) - [x] LiveComponent dehydration/hydration issues (`null` values are lost during re-render) - solved in #264 Commits ------- c1e484b [Twig][Live] null attribute values render without value (ie autofocus)
2 parents 6d6d047 + 2650608 commit 55c4b36

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tests/Integration/LiveComponentHydratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ public function testCanDehydrateAndHydrateComponentsWithAttributes(): void
274274
$factory = self::getContainer()->get('ux.twig_component.component_factory');
275275

276276
/** @var ComponentWithAttributes $component */
277-
$component = $factory->create('with_attributes', $attributes = ['class' => 'foo']);
277+
$component = $factory->create('with_attributes', $attributes = ['class' => 'foo', 'value' => null]);
278278

279279
$this->assertSame($attributes, $component->attributes->all());
280280

0 commit comments

Comments
 (0)