Skip to content

Commit f7988c1

Browse files
authored
Merge pull request #86 from mik-laj/master
Accessibility icons
2 parents 0fc33eb + 2d8ad33 commit f7988c1

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

src/View/Helper/BootstrapHtmlHelper.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public function icon ($icon, $options = []) {
8686
public function faIcon ($icon, $options = []) {
8787
$options = $this->addClass($options, 'fa');
8888
$options = $this->addClass($options, 'fa-'.$icon);
89+
$options += [
90+
'aria-hidden' => 'true'
91+
];
8992

9093
return $this->tag('i', '', $options);
9194
}
@@ -98,6 +101,9 @@ public function faIcon ($icon, $options = []) {
98101
public function glIcon ($icon, $options = []) {
99102
$options = $this->addClass($options, 'glyphicon');
100103
$options = $this->addClass($options, 'glyphicon-'.$icon);
104+
$options += [
105+
'aria-hidden' => 'true'
106+
];
101107

102108
return $this->tag('i', '', $options);
103109
}

tests/TestCase/View/Helper/BootstrapHtmlHelperTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,31 +55,35 @@ public function testIcon () {
5555
// Default icon (Glyphicon)
5656
$this->assertHtml ([
5757
['i' => [
58-
'class' => 'glyphicon glyphicon-'.$type
58+
'class' => 'glyphicon glyphicon-'.$type,
59+
'aria-hidden' => 'true'
5960
]],
6061
'/i'
6162
], $this->Html->icon($type));
6263
$this->assertHtml ([
6364
['i' => [
6465
'class' => $options['class'].' glyphicon glyphicon-'.$type,
65-
'id' => $options['id']
66+
'id' => $options['id'],
67+
'aria-hidden' => 'true'
6668
]],
6769
'/i'
6870
], $this->Html->icon($type, $options));
6971
// FontAwesome icon
7072
$this->assertHtml ([
7173
['i' => [
72-
'class' => 'fa fa-'.$type
74+
'class' => 'fa fa-'.$type,
75+
'aria-hidden' => 'true'
7376
]],
7477
'/i'
7578
], $this->Html->faIcon($type));
7679
$this->assertHtml ([
7780
['i' => [
7881
'class' => $options['class'].' fa fa-'.$type,
79-
'id' => $options['id']
82+
'id' => $options['id'],
83+
'aria-hidden' => 'true'
8084
]],
8185
'/i'
82-
], $this->Html->faIcon($type, $options));
86+
], $this->Html->faIcon($type, $options));
8387
}
8488

8589
public function testLabel () {

tests/TestCase/View/Helper/BootstrapPaginatorHelperTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ public function testPrev () {
5959
]],
6060
['a' => true],
6161
['i' => [
62-
'class' => 'glyphicon glyphicon-chevron-left'
62+
'class' => 'glyphicon glyphicon-chevron-left',
63+
'aria-hidden' => 'true'
6364
]],
6465
'/i', '/a', '/li'
6566
], $this->Paginator->prev('i:chevron-left'));
@@ -79,7 +80,8 @@ public function testNext () {
7980
'href' => '/index?page=2'
8081
]],
8182
['i' => [
82-
'class' => 'glyphicon glyphicon-chevron-right'
83+
'class' => 'glyphicon glyphicon-chevron-right',
84+
'aria-hidden' => 'true'
8385
]],
8486
'/i', '/a', '/li'
8587
], $this->Paginator->next('i:chevron-right'));

tests/TestCase/View/Helper/BootstrapPanelHelperTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public function testHeader () {
136136
'class' => 'panel-title'
137137
]],
138138
['i' => [
139-
'class' => 'glyphicon glyphicon-home'
139+
'class' => 'glyphicon glyphicon-home',
140+
'aria-hidden' => 'true'
140141
]], '/i', ' Home',
141142
'/h4',
142143
'/div'
@@ -215,7 +216,8 @@ public function testHeader () {
215216
'aria-controls' => '#collapse-2'
216217
]],
217218
['i' => [
218-
'class' => 'glyphicon glyphicon-home'
219+
'class' => 'glyphicon glyphicon-home',
220+
'aria-hidden' => 'true'
219221
]], '/i', ' Home',
220222
'/a',
221223
'/h4',

tests/TestCase/View/Helper/BootstrapTraitTest.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ public function testEasyIcon() {
8282
'expected' => [
8383
'escape' => false,
8484
'result' => [['i' => [
85-
'class' => 'glyphicon glyphicon-plus'
85+
'class' => 'glyphicon glyphicon-plus',
86+
'aria-hidden' => 'true'
8687
]], '/i']
8788
]
8889
]);
@@ -98,7 +99,8 @@ public function testEasyIcon() {
9899
'expected' => [
99100
'escape' => false,
100101
'result' => [['i' => [
101-
'class' => 'glyphicon glyphicon-plus'
102+
'class' => 'glyphicon glyphicon-plus',
103+
'aria-hidden' => 'true'
102104
]], '/i', ' Add']
103105
]
104106
]);
@@ -107,7 +109,8 @@ public function testEasyIcon() {
107109
'expected' => [
108110
'escape' => false,
109111
'result' => ['Add ', ['i' => [
110-
'class' => 'glyphicon glyphicon-plus'
112+
'class' => 'glyphicon glyphicon-plus',
113+
'aria-hidden' => 'true'
111114
]], '/i']
112115
]
113116
]);
@@ -136,7 +139,8 @@ public function testHelperMethods() {
136139
'class' => 'btn btn-default',
137140
'type' => 'submit'
138141
]], ['i' => [
139-
'class' => 'glyphicon glyphicon-plus'
142+
'class' => 'glyphicon glyphicon-plus',
143+
'aria-hidden' => 'true'
140144
]], '/i', '/button'
141145
], $result) ;
142146
$result = $this->Form->input ('fieldname', [
@@ -154,7 +158,10 @@ public function testHelperMethods() {
154158
['span' => [
155159
'class' => 'input-group-addon'
156160
]],
157-
['i' => ['class' => 'glyphicon glyphicon-home']], '/i',
161+
['i' => [
162+
'class' => 'glyphicon glyphicon-home',
163+
'aria-hidden' => 'true'
164+
]], '/i',
158165
'/span',
159166
['input' => [
160167
'type' => 'text',
@@ -165,7 +172,10 @@ public function testHelperMethods() {
165172
['span' => [
166173
'class' => 'input-group-addon'
167174
]],
168-
['i' => ['class' => 'glyphicon glyphicon-plus']], '/i',
175+
['i' => [
176+
'class' => 'glyphicon glyphicon-plus',
177+
'aria-hidden' => 'true'
178+
]], '/i',
169179
'/span',
170180
'/div',
171181
'/div'

0 commit comments

Comments
 (0)