Class: ERBLint::Linters::GitHub::Accessibility::NavigationHasLabel
- Inherits:
-
Linter
- Object
- Linter
- ERBLint::Linters::GitHub::Accessibility::NavigationHasLabel
- Includes:
- CustomHelpers, LinterRegistry
- Defined in:
- lib/erblint-github/linters/github/accessibility/navigation_has_label.rb
Constant Summary collapse
- MESSAGE =
"The navigation landmark should have a unique accessible name via `aria-label` or `aria-labelledby`. Remember that the name does not need to include `navigation` or `nav` since it will already be announced."
Constants included from CustomHelpers
CustomHelpers::INTERACTIVE_ELEMENTS
Instance Method Summary collapse
Methods included from CustomHelpers
#basic_conditional_code_check, #counter_correct?, #focusable?, #generate_offense, #generate_offense_from_source_range, #possible_attribute_values, #simple_class_name, #tags
Instance Method Details
#run(processed_source) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/erblint-github/linters/github/accessibility/navigation_has_label.rb', line 15 def run(processed_source) (processed_source).each do |tag| next if tag.closing? next unless possible_attribute_values(tag, "role").include?("navigation") || tag.name == "nav" if possible_attribute_values(tag, "aria-label").empty? && possible_attribute_values(tag, "aria-labelledby").empty? = MESSAGE if tag.name != "nav" += "Additionally, you can safely drop the `role='navigation'` and replace it with the native HTML `nav` element." end generate_offense(self.class, processed_source, tag, ) end end end |