getAttribute('role'))); if ($role === 'tree') { $hasName = ($element->hasAttribute('aria-label') && trim($element->getAttribute('aria-label')) !== '') || ($element->hasAttribute('aria-labelledby') && trim($element->getAttribute('aria-labelledby')) !== ''); if (!$hasName) { return $this->createViolation( $element, 'Element with role="tree" is missing an accessible name (aria-label or aria-labelledby).', 'Add aria-label="File Explorer" or aria-labelledby referencing a visible heading.' ); } return null; } if ($role === 'treeitem') { $doc = $element->ownerDocument; if ($doc !== null) { $xpath = new DOMXPath($doc); $nestedGroup = $xpath->query('./*[@role="group"] | ./ul | ./ol', $element); if ($nestedGroup !== false && $nestedGroup->length > 0 && !$element->hasAttribute('aria-expanded')) { return $this->createViolation( $element, 'Parent element with role="treeitem" contains nested child items without an aria-expanded attribute.', 'Add aria-expanded="true" or aria-expanded="false" to expandable treeitem nodes.' ); } } } return null; } }