From d55e7fa9ee60a22be8c875f9a79ce8c562cd60ee Mon Sep 17 00:00:00 2001 From: Brian Teeman Date: Fri, 1 Jan 2021 12:35:07 +0000 Subject: [PATCH] [4.0] html5 chrome fix [a11y] and markup (#31772) Co-authored-by: Quy --- layouts/chromes/html5.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/layouts/chromes/html5.php b/layouts/chromes/html5.php index 8cd7622773e4b..7e370844d18a7 100644 --- a/layouts/chromes/html5.php +++ b/layouts/chromes/html5.php @@ -29,14 +29,23 @@ $headerTag = htmlspecialchars($params->get('header_tag', 'h3'), ENT_QUOTES, 'UTF-8'); $headerClass = htmlspecialchars($params->get('header_class', ''), ENT_QUOTES, 'UTF-8'); $headerAttribs = []; -$headerAttribs['class'] = $headerClass; - -if ($module->showtitle) : - $moduleAttribs['aria-labelledby'] = 'mod-' . $module->id; - $headerAttribs['id'] = 'mod-' . $module->id; -else: - $moduleAttribs['aria-label'] = $module->title; -endif; + +// Only output a header class if one is set +if ($headerClass !== '') +{ + $headerAttribs['class'] = $headerClass; +} + +// Only add aria if the moduleTag is not a div +if ($moduleTag !== 'div') +{ + if ($module->showtitle) : + $moduleAttribs['aria-labelledby'] = 'mod-' . $module->id; + $headerAttribs['id'] = 'mod-' . $module->id; + else: + $moduleAttribs['aria-label'] = $module->title; + endif; +} $header = '<' . $headerTag . ' ' . ArrayHelper::toString($headerAttribs) . '>' . $module->title . ''; ?>