Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 227ddfd

Browse files
committed
Merge branch 'hotfix/38'
Close #38
2 parents 56e3a84 + 9c6bdf8 commit 227ddfd

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ All notable changes to this project will be documented in this file, in reverse
2323
instance, it is populated with the `InputFilterFactory` present in its own
2424
`FormFactory`. This ensures that any custom inputs, input filters, validators,
2525
or filters are available to the new instance.
26+
- [#38](https://github.com/zendframework/zend-form/pull/38) removes the
27+
arbitrary restriction of only the "labelledby" and "describedby" aria
28+
attributes on form element view helpers; any aria attribute is now allowed.
2629

2730
## 2.7.0 - 2016-02-22
2831

src/View/Helper/AbstractHelper.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@ abstract class AbstractHelper extends BaseAbstractHelper
130130
'onvolumechange' => true,
131131
'onwaiting' => true,
132132
'role' => true,
133-
'aria-labelledby' => true,
134-
'aria-describedby' => true,
135133
'spellcheck' => true,
136134
'style' => true,
137135
'tabindex' => true,
@@ -355,6 +353,7 @@ protected function prepareAttributes(array $attributes)
355353
if (!isset($this->validGlobalAttributes[$attribute])
356354
&& !isset($this->validTagAttributes[$attribute])
357355
&& 'data-' != substr($attribute, 0, 5)
356+
&& 'aria-' != substr($attribute, 0, 5)
358357
&& 'x-' != substr($attribute, 0, 2)
359358
) {
360359
// Invalid attribute for the current tag

test/ElementTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,35 @@ public function testCanRemoveMultipleLabelOptions()
330330
$this->assertFalse($element->hasLabelOption('foo2'));
331331
$this->assertTrue($element->hasLabelOption('foo3'));
332332
}
333+
334+
public function testCanAddMultipleAriaAttributes()
335+
{
336+
$element = new Element();
337+
$attributes = [
338+
'type' => 'text',
339+
'aria-label' => 'alb',
340+
'aria-describedby' => 'adb',
341+
'aria-orientation' => 'vertical'
342+
];
343+
$element->setAttributes($attributes);
344+
$this->assertTrue($element->hasAttribute('aria-describedby'));
345+
$this->assertTrue($element->hasAttribute('aria-label'));
346+
$this->assertTrue($element->hasAttribute('aria-orientation'));
347+
}
348+
349+
public function testCanRemoveMultipleAriaAttributes()
350+
{
351+
$element = new Element();
352+
$attributes = [
353+
'type' => 'text',
354+
'aria-label' => 'alb',
355+
'aria-describedby' => 'adb',
356+
'aria-orientation' => 'vertical'
357+
];
358+
$element->setAttributes($attributes);
359+
$element->removeAttributes(['aria-label', 'aria-describedby', 'aria-orientation']);
360+
$this->assertFalse($element->hasAttribute('aria-describedby'));
361+
$this->assertFalse($element->hasAttribute('aria-label'));
362+
$this->assertFalse($element->hasAttribute('aria-orientation'));
363+
}
333364
}

0 commit comments

Comments
 (0)