diff --git a/composer.json b/composer.json index 500f7eb..f64bf70 100644 --- a/composer.json +++ b/composer.json @@ -12,7 +12,7 @@ "yaknet" ], "homepage": "https://forum.yak.net.tr", - "version": "3.1.3", + "version": "3.1.4", "type": "library", "license": "MIT", "authors": [ diff --git a/src/Rules/AnchorMissingHref.php b/src/Rules/AnchorMissingHref.php new file mode 100644 index 0000000..474bc79 --- /dev/null +++ b/src/Rules/AnchorMissingHref.php @@ -0,0 +1,38 @@ +) acting as links must have a valid href attribute.'; } + public function getStandard(): WCAGStandard { return WCAGStandard::A; } + public function getSeverity(): Severity { return Severity::WARNING; } + public function getLevel(): int { return 2; } + + public function check(DOMElement $element): ?Violation + { + if (strtolower($element->tagName) !== 'a') { + return null; + } + + if ($element->hasAttribute('name') || $element->hasAttribute('role')) { + return null; + } + + if (!$element->hasAttribute('href') || trim($element->getAttribute('href')) === '') { + return $this->createViolation( + $element, + $this->getDescription(), + 'Add a valid href attribute to the element, or use a