mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
Merge branch 'MDL-82812_master_toolbrickfieldfaicons' of https://github.com/brickfield/moodle
This commit is contained in:
commit
57880e1b40
@ -16,7 +16,7 @@
|
||||
|
||||
namespace tool_brickfield\local\htmlchecker\common\checks;
|
||||
|
||||
use tool_brickfield\local\htmlchecker\common\brickfield_accessibility_tag_test;
|
||||
use tool_brickfield\local\htmlchecker\common\brickfield_accessibility_test;
|
||||
|
||||
/**
|
||||
* Brickfield accessibility HTML checker library.
|
||||
@ -28,11 +28,25 @@ use tool_brickfield\local\htmlchecker\common\brickfield_accessibility_tag_test;
|
||||
* @copyright 2020 onward: Brickfield Education Labs, www.brickfield.ie
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class i_is_not_used extends brickfield_accessibility_tag_test {
|
||||
class i_is_not_used extends brickfield_accessibility_test {
|
||||
|
||||
/** @var int The default severity code for this test. */
|
||||
public $defaultseverity = \tool_brickfield\local\htmlchecker\brickfield_accessibility::BA_TEST_SEVERE;
|
||||
|
||||
/** @var string The tag this test will fire on. */
|
||||
public $tag = 'i';
|
||||
|
||||
/**
|
||||
* Check for any i elements and flag them as errors
|
||||
* while allowing font awesome icons to be used.
|
||||
*/
|
||||
public function check(): void {
|
||||
foreach ($this->get_all_elements('i') as $element) {
|
||||
// Ensure this is not a font awesome icon with aria-hidden.
|
||||
if (str_contains($element->getAttribute('class'), 'fa-') && $element->getAttribute('aria-hidden') === 'true') {
|
||||
continue;
|
||||
}
|
||||
$this->add_report($element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +30,8 @@ require_once('all_checks.php');
|
||||
|
||||
/**
|
||||
* Class i_is_not_used_testcase
|
||||
*
|
||||
* @covers \tool_brickfield\local\htmlchecker\common\checks\i_is_not_used
|
||||
*/
|
||||
class i_is_not_used_test extends all_checks {
|
||||
/** @var string Check type */
|
||||
@ -71,4 +73,13 @@ EOD;
|
||||
$results = $this->get_checker_results($this->htmlpass);
|
||||
$this->assertEmpty($results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for font awesome icon.
|
||||
*/
|
||||
public function test_fa_icon(): void {
|
||||
$html = '<div><i class="fa fa-user"></i><i>Hello there</i><i class="fa fa-address-book" aria-hidden="true"></i></div>';
|
||||
$results = $this->get_checker_results($html);
|
||||
$this->assertCount(2, $results);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user