From 0e55333a86ecdda78d149e347b41c673dd6b6c07 Mon Sep 17 00:00:00 2001 From: Eric Merrill Date: Tue, 22 Sep 2015 17:14:17 -0400 Subject: [PATCH] MDL-51501 themes: pix_icon should not include empty alt tags --- lib/outputcomponents.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/outputcomponents.php b/lib/outputcomponents.php index 4efe670aafd..7e858301ca7 100644 --- a/lib/outputcomponents.php +++ b/lib/outputcomponents.php @@ -533,13 +533,23 @@ class pix_icon implements renderable, templatable { $this->component = $component; $this->attributes = (array)$attributes; - $this->attributes['alt'] = $alt; if (empty($this->attributes['class'])) { $this->attributes['class'] = 'smallicon'; } - if (!isset($this->attributes['title'])) { - $this->attributes['title'] = $this->attributes['alt']; - } else if (empty($this->attributes['title'])) { + + // If the alt is empty, don't place it in the attributes, otherwise it will override parent alt text. + if (!is_null($alt)) { + $this->attributes['alt'] = $alt; + + // If there is no title, set it to the attribute. + if (!isset($this->attributes['title'])) { + $this->attributes['title'] = $this->attributes['alt']; + } + } else { + unset($this->attributes['alt']); + } + + if (empty($this->attributes['title'])) { // Remove the title attribute if empty, we probably want to use the parent node's title // and some browsers might overwrite it with an empty title. unset($this->attributes['title']); -- 2.43.0