Class: ERBLint::Linters::GitHub::Accessibility::IframeHasTitle

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

Constant Summary collapse

MESSAGE =
"`<iframe>` with meaningful content should have a title attribute that identifies the content."\
" If `<iframe>` has no meaningful content, hide it from assistive technology with `aria-hidden='true'`."

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



16
17
18
19
20
21
22
23
24
25
# File 'lib/erblint-github/linters/github/accessibility/iframe_has_title.rb', line 16

def run(processed_source)
  tags(processed_source).each do |tag|
    next if tag.name != "iframe"
    next if tag.closing?

    title = possible_attribute_values(tag, "title")

    generate_offense(self.class, processed_source, tag) if title.empty? && !aria_hidden?(tag)
  end
end