<commit_before>module SimpleForm
  module Components
    module HTML5
      def initialize(*)
        @html5 = false
      end

      def html5(wrapper_options = nil)
        @html5 = true

        input_html_options[:required]        = has_required?
        input_html_options[:'aria-required'] = has_required? || nil

        input_html_options[:'aria-invalid']  = has_errors?

        nil
      end

      def html5?
        @html5
      end

      def has_required?
        # We need to check browser_validations because
        # some browsers are still checking required even
        # if novalidate was given.
        required_field? && SimpleForm.browser_validations
      end
    end
  end
end
<commit_msg>Do not emit `aria-invalid="false"` attributes for inputs without errors.<commit_after>module SimpleForm
  module Components
    module HTML5
      def initialize(*)
        @html5 = false
      end

      def html5(wrapper_options = nil)
        @html5 = true

        input_html_options[:required]        = has_required?
        input_html_options[:'aria-required'] = has_required? || nil

        input_html_options[:'aria-invalid']  = has_errors? || nil

        nil
      end

      def html5?
        @html5
      end

      def has_required?
        # We need to check browser_validations because
        # some browsers are still checking required even
        # if novalidate was given.
        required_field? && SimpleForm.browser_validations
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.06885026737967914, 'fraction_numerical': 0.008021390374331552, 'mean_word_length': 2.1515789473684213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2630109', 'n_tokens_mistral': 425, 'n_tokens_neox': 406, 'n_words': 117}