Class: ERBLint::Linters::GitHub::Accessibility::DisabledAttribute

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

Constant Summary collapse

VALID_DISABLED_TAGS =
%w[button input textarea option select fieldset optgroup task-lists].freeze
MESSAGE =
"`disabled` is only valid on #{VALID_DISABLED_TAGS.join(', ')}."

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

def run(processed_source)
  tags(processed_source).each do |tag|
    next if tag.closing?
    next if VALID_DISABLED_TAGS.include?(tag.name)
    next if tag.attributes["disabled"].nil?

    generate_offense(self.class, processed_source, tag)
  end
end