File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
src/Tempest/View/src/Elements Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 44
55namespace Tempest \View \Elements ;
66
7+ use function Tempest \Support \str ;
78use Tempest \View \Element ;
89
910final class GenericElement implements Element
@@ -30,6 +31,14 @@ public function compile(): string
3031 $ attributes = [];
3132
3233 foreach ($ this ->getAttributes () as $ name => $ value ) {
34+ $ name = str ($ name );
35+
36+ if ($ name ->startsWith (': ' )) {
37+ $ name = ': ' . $ name ->kebab ()->toString ();
38+ } else {
39+ $ name = $ name ->kebab ()->toString ();
40+ }
41+
3342 if ($ value ) {
3443 $ attributes [] = $ name . '=" ' . $ value . '" ' ;
3544 } else {
Original file line number Diff line number Diff line change @@ -356,4 +356,20 @@ public function test_no_double_forelse_attributes(): void
356356HTML, foo: []),
357357 );
358358 }
359+
360+ public function test_render_element_with_attribute_with_dash (): void
361+ {
362+ $ view = view (
363+ <<<HTML
364+ <div data-theme="tempest"></div>
365+ HTML ,
366+ );
367+
368+ $ html = $ this ->render ($ view );
369+
370+ $ this ->assertStringContainsString (
371+ '<div data-theme="tempest"></div> ' ,
372+ $ html ,
373+ );
374+ }
359375}
You can’t perform that action at this time.
0 commit comments