Issue #2605420 by IRuslan, joelpittet: Missing aria-pressed template_preprocess_details() due to lost copied attributes in Attribute
parent
1f0466c48c
commit
19e1f2f108
|
@ -117,10 +117,11 @@ class Attribute implements \ArrayAccess, \IteratorAggregate, MarkupInterface {
|
||||||
* An AttributeValueBase representation of the attribute's value.
|
* An AttributeValueBase representation of the attribute's value.
|
||||||
*/
|
*/
|
||||||
protected function createAttributeValue($name, $value) {
|
protected function createAttributeValue($name, $value) {
|
||||||
// If the value is already an AttributeValueBase object, return it
|
// If the value is already an AttributeValueBase object,
|
||||||
// straight away.
|
// return a new instance of the same class, but with the new name.
|
||||||
if ($value instanceof AttributeValueBase) {
|
if ($value instanceof AttributeValueBase) {
|
||||||
return $value;
|
$class = get_class($value);
|
||||||
|
return new $class($name, $value->value());
|
||||||
}
|
}
|
||||||
// An array value or 'class' attribute name are forced to always be an
|
// An array value or 'class' attribute name are forced to always be an
|
||||||
// AttributeArray value for consistency.
|
// AttributeArray value for consistency.
|
||||||
|
|
|
@ -71,4 +71,20 @@ class AttributesTest extends UnitTestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test AttributeValueBase copy.
|
||||||
|
*/
|
||||||
|
public function testAttributeValueBaseCopy() {
|
||||||
|
$original_attributes = new Attribute([
|
||||||
|
'checked' => TRUE,
|
||||||
|
'class' => ['who', 'is', 'on'],
|
||||||
|
'id' => 'first',
|
||||||
|
]);
|
||||||
|
$attributes['selected'] = $original_attributes['checked'];
|
||||||
|
$attributes['id'] = $original_attributes['id'];
|
||||||
|
$attributes = new Attribute($attributes);
|
||||||
|
$this->assertSame((string) $original_attributes, ' checked class="who is on" id="first"', 'Original boolean value used with original name.');
|
||||||
|
$this->assertSame((string) $attributes, ' selected id="first"', 'Original boolean value used with new name.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue