Class: ERBLint::Linters::GitHub::Accessibility::NoAriaHiddenOnFocusable

Inherits:
Linter
  • Object
show all
Includes:
CustomHelpers, LinterRegistry
Defined in:
lib/erblint-github/linters/github/accessibility/no_aria_hidden_on_focusable.rb

Constant Summary collapse

MESSAGE =
"Elements that are focusable should not have `aria-hidden='true' because it will cause confusion for assistive technology users."

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
# File 'lib/erblint-github/linters/github/accessibility/no_aria_hidden_on_focusable.rb', line 15

def run(processed_source)
  tags(processed_source).each do |tag|
    aria_hidden = possible_attribute_values(tag, "aria-hidden")
    generate_offense(self.class, processed_source, tag) if aria_hidden.include?("true") && focusable?(tag)
  end
end