commit 9317ef39e9f2d8d6f93c8f50f44e70efba46d900 Author: Joel Pittet Date: Mon Aug 4 14:55:26 2014 -0700 unique and docs diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php index 1188467..075ef8b 100644 --- a/core/lib/Drupal/Core/Template/Attribute.php +++ b/core/lib/Drupal/Core/Template/Attribute.php @@ -119,7 +119,7 @@ public function offsetExists($name) { /** * Adds argument values by merging them on to array of existing CSS classes. * - * @param mixed ... + * @param string|array ... * CSS classes to add to the class attribute array. * * @return $this @@ -139,12 +139,12 @@ public function addClass() { // Merge the values passed in from the class value array. $classes = array_merge($this->storage['class']->value(), $classes); // Filter out any empty values. - $classes = array_filter($classes); + $classes = array_unique(array_filter($classes)); $this->storage['class']->exchangeArray($classes); } else { // Filter out any empty values. - $classes = array_filter($classes); + $classes = array_unique(array_filter($classes)); $this->offsetSet('class', $classes); } @@ -154,7 +154,7 @@ public function addClass() { /** * Removes argument values from array of existing CSS classes. * - * @param mixed ... + * @param string|array ... * CSS classes to remove from the class attribute array. * * @return $this @@ -174,7 +174,7 @@ public function removeClass() { // Remove the values passed in from the value array. $classes = array_diff($this->storage['class']->value(), $classes); // Filter out any empty values. - $classes = array_filter($classes); + $classes = array_unique(array_filter($classes)); $this->storage['class']->exchangeArray($classes); } return $this;