Skip to content
This repository was archived by the owner on Mar 5, 2023. It is now read-only.

Commit b0da464

Browse files
authoredJun 4, 2020
Merge pull request #20 from 8fold/8fold-sites
aria-expanded, pressed for button
2 parents 681698b + 9efa1b6 commit b0da464

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed
 

‎src/Html/Data/Attributes/Aria.php

+11
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ static public function dropeffect(): array
100100
{
101101
return ['aria-dropeffect'];
102102
}
103+
104+
static public function expanded(): array
105+
{
106+
return ['aria-expanded'];
107+
}
108+
109+
static public function pressed(): array
110+
{
111+
return ['aria-pressed'];
112+
}
113+
103114
static public function flowto(): array
104115
{
105116
return ['aria-flowto'];

‎src/Html/Elements/Forms/Button.php

+10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Eightfold\Markup\Html\Data\Elements;
99
use Eightfold\Markup\Html\Data\AriaRoles;
10+
use Eightfold\Markup\Html\Data\Attributes\Aria;
1011

1112
use Eightfold\Markup\Html\Data\Attributes\Content;
1213

@@ -83,4 +84,13 @@ static public function optionalAriaRoles(): array
8384
AriaRoles::radio()
8485
);
8586
}
87+
88+
static public function optionalAriaAttributes(): array
89+
{
90+
return array_merge(
91+
parent::optionalAriaAttributes(),
92+
Aria::expanded(),
93+
Aria::pressed()
94+
);
95+
}
8696
}

‎tests/html/HtmlTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,11 @@ public function testCanHaveAriaHidden()
9393
$actual = Html::div()->attr("aria-hidden true");
9494
$this->assertSame($expected, $actual->unfold());
9595
}
96+
97+
public function testCanHaveAriaExpanded()
98+
{
99+
$expected = '<button aria-expanded="false"></button>';
100+
$actual = Html::button()->attr("aria-expanded false");
101+
$this->assertEquals($expected, $actual->unfold());
102+
}
96103
}

0 commit comments

Comments
 (0)
This repository has been archived.