Commit 17add477 authored by Denis Chenu's avatar Denis Chenu

[fix] Don't add empty aria-labelledby

parent 6fa5036d
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* @author Denis Chenu <denis@sondages.pro> * @author Denis Chenu <denis@sondages.pro>
* @copyright 2015-2016 Denis Chenu <http://www.sondages.pro> * @copyright 2015-2016 Denis Chenu <http://www.sondages.pro>
* @license GPL v3 * @license GPL v3
* @version 1.4.0 * @version 1.5.1
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
...@@ -96,10 +96,12 @@ class moreAccessibility extends PluginBase ...@@ -96,10 +96,12 @@ class moreAccessibility extends PluginBase
foreach($dom->getElementsByTagName('label') as $label) foreach($dom->getElementsByTagName('label') as $label)
$label->parentNode->removeChild($label); $label->parentNode->removeChild($label);
$input=$dom->getElementById($sAnswerId); $input=$dom->getElementById($sAnswerId);
if($input) if(!empty($aLabelledBy)) {
$input->setAttribute("aria-labelledby",implode(" ",$aLabelledBy)); if($input)
else $input->setAttribute("aria-labelledby",implode(" ",$aLabelledBy));
tracevar("{$sAnswerId} Is not found in HTML produced for answers"); else
tracevar("{$sAnswerId} Is not found in HTML produced for answers");
}
$newHtml = $dom->saveHTMLExact(); $newHtml = $dom->saveHTMLExact();
$oEvent->set('answers',$newHtml); $oEvent->set('answers',$newHtml);
} }
...@@ -216,7 +218,9 @@ class moreAccessibility extends PluginBase ...@@ -216,7 +218,9 @@ class moreAccessibility extends PluginBase
foreach ($dom->getElementsByTagName('table') as $elTable) foreach ($dom->getElementsByTagName('table') as $elTable)
{ {
$elTable->setAttribute('role','group'); $elTable->setAttribute('role','group');
$elTable->setAttribute('aria-labelledby',implode(" ",$aGlobalDescribedBy)); if(!empty($aGlobalDescribedBy)) {
$elTable->setAttribute('aria-labelledby',implode(" ",$aGlobalDescribedBy));
}
// Fix update summary ? Add aria-hidden to head ? // Fix update summary ? Add aria-hidden to head ?
} }
switch ($sType) switch ($sType)
...@@ -267,7 +271,6 @@ class moreAccessibility extends PluginBase ...@@ -267,7 +271,6 @@ class moreAccessibility extends PluginBase
} }
} }
} }
$newHtml = $dom->saveHTMLExact(); $newHtml = $dom->saveHTMLExact();
$oEvent->set('answers',$newHtml); $oEvent->set('answers',$newHtml);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment