Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore the problematics HTML validation checks with hidden inputs #10020

Merged
33 changes: 33 additions & 0 deletions decidim-dev/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
# frozen_string_literal: true

# This is a temporary fix to ignore some HTML/CSS validation issues with the
# Decidim HTML validation process.
#
# See: https://github.com/decidim/decidim/pull/10014
# Related: https://github.com/rails/rails/issues/46405
ahukkanen marked this conversation as resolved.
Show resolved Hide resolved
module W3CValidators
class NuValidator
protected

alias validate_nu validate unless method_defined?(:validate_nu)

def validate(options) # :nodoc:
filter_results(validate_nu(options))
end

def ignore_errors
@ignore_errors ||= [
"An “input” element with a “type” attribute whose value is “hidden” must not have an “autocomplete” attribute whose value is “on” or “off”."
ahukkanen marked this conversation as resolved.
Show resolved Hide resolved
]
end

def filter_results(results)
messages = results.instance_variable_get(:@messages)
messages.delete_if do |msg|
msg.is_error? && ignore_errors.include?(msg.message)
end
results.instance_variable_set(:@validity, messages.none?(&:is_error?))

results
end
end
end

# This allows us to dynamically load the validator URL from the ENV.
module W3cRspecValidators
class Config
Expand Down