parentNode; while ($parent instanceof DOMElement) { if (strtolower($parent->tagName) === $target) { return true; } $parent = $parent->parentNode; } return false; } /** * Get accessible name / visible text from element including aria-label and title. */ public static function getAccessibleName(DOMElement $element): string { if ($element->hasAttribute('aria-label')) { return trim($element->getAttribute('aria-label')); } if ($element->hasAttribute('title')) { return trim($element->getAttribute('title')); } return trim($element->textContent); } }