Class: ERBLint::Linters::GitHub::Accessibility::NestedInteractiveElements
- Inherits:
-
Linter
- Object
- Linter
- ERBLint::Linters::GitHub::Accessibility::NestedInteractiveElements
- Includes:
- CustomHelpers, LinterRegistry
- Defined in:
- lib/erblint-github/linters/github/accessibility/nested_interactive_elements.rb
Constant Summary collapse
- MESSAGE =
"Nesting interactive elements produces invalid HTML, and ssistive technologies, such as screen readers, might ignore or respond unexpectedly to such nested controls."
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 29 30 31 32 33 |
# File 'lib/erblint-github/linters/github/accessibility/nested_interactive_elements.rb', line 15 def run(processed_source) last_interactive_element = nil (processed_source).each do |tag| next unless INTERACTIVE_ELEMENTS.include?(tag.name) last_interactive_element = nil if last_interactive_element && tag.name == last_interactive_element.name && tag.closing? next if tag.closing? if last_interactive_element next if last_interactive_element.name == "summary" && tag.name == "a" next if tag.name == "input" && tag.attributes["type"]&.value == "hidden" = "Found <#{tag.name}> nested inside of <#{last_interactive_element.name}>.\n" + MESSAGE generate_offense(self.class, processed_source, tag, ) end last_interactive_element = tag unless tag&.name == "input" end end |