Skip to content
Snippets Groups Projects
Commit 19e1f2f1 authored by catch's avatar catch
Browse files

Issue #2605420 by IRuslan, joelpittet: Missing aria-pressed...

Issue #2605420 by IRuslan, joelpittet: Missing aria-pressed template_preprocess_details() due to lost copied attributes in Attribute
parent 1f0466c4
No related branches found
No related tags found
No related merge requests found
......@@ -117,10 +117,11 @@ public function offsetSet($name, $value) {
* An AttributeValueBase representation of the attribute's value.
*/
protected function createAttributeValue($name, $value) {
// If the value is already an AttributeValueBase object, return it
// straight away.
// If the value is already an AttributeValueBase object,
// return a new instance of the same class, but with the new name.
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
// AttributeArray value for consistency.
......
......@@ -71,4 +71,20 @@ public function testAttributeIteration() {
}
}
/**
* 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.');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment