-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add html-validation to detect malformed markup #15433
Conversation
A bugfix without a regression test… surely not? ;) |
@tmtmtmtm should I research into adding something that runs a check against the W3C validator when running the web tests |
I don't think you need to run against an external validator. Nokogiri in strict mode is probably all we need. Changing the it "has no HTML errors" do
subject.errors.must_be_empty
end |
c98a2bc
to
28a3f23
Compare
28a3f23
to
94799f0
Compare
@octopusinvitro – This looks fine to me, apart from the “Search by country name” hint text now being missing from the search input on the homepage. Before: After: The text input (generated by selectToAutocomplete) uses |
ea3e99b
to
efb0521
Compare
efb0521
to
7363a0f
Compare
7363a0f
to
48b7972
Compare
Errors corrected: - An "img" element must have an "alt" attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. (All occurrences)
Errors corrected: - An "img" element must have an "alt" attribute, except under certain conditions. For details, consult guidance on providing text alternatives for images. At line 254, column 69. - End tag "div" seen, but there were open elements. At line 256, column 12. - Unclosed element "a". At line 252, column 77.
Errors corrected: - No errors
Errors corrected: - No errors
Errors corrected: - Attribute "placeholder" not allowed on element "select" at this point. At line 86, column 189 - Attribute "autocorrect" not allowed on element "select" at this point. At line 86, column 189 - Attribute "autocomplete" not allowed on element "select" at this point. At line 86, column 189 - & did not start a character reference. (& probably should have been escaped as &.) At line 1140, column 93 - & did not start a character reference. (& probably should have been escaped as &.) At line 1140, column 123 - & did not start a character reference. (& probably should have been escaped as &.) At line 1140, column 139 - & did not start a character reference. (& probably should have been escaped as &.) At line 1152, column 90 - & did not start a character reference. (& probably should have been escaped as &.) At line 1152, column 114 - & did not start a character reference. (& probably should have been escaped as &.) At line 1152, column 130 - & did not start a character reference. (& probably should have been escaped as &.) At line 1159, column 219 - & did not start a character reference. (& probably should have been escaped as &.) At line 1159, column 256 - & did not start a character reference. (& probably should have been escaped as &.) At line 1159, column 272
05ec677
to
2337c51
Compare
@tmtmtmtm I rebased all commits in the PR to:
Closes #15562 |
@@ -305,6 +305,11 @@ $(function(){ | |||
}); | |||
|
|||
// http://baymard.com/labs/country-selector | |||
$('.js-select-to-autocomplete').attr({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A small thing, but it’s generally good practice to avoid querying the DOM more often than is necessary. So, you might query the DOM once and then cache the result in a variable to be reused again later:
var $select = $('.js-select-to-autocomplete');
$select.attr({ … });
$select.selectToAutoComplete();
$select.on('change', function(){ … });
Or, since you have a fairly small number of methods to call, you could save the overhead of another variable, and just use jQuery chaining:
$('.js-select-to-autocomplete')
.attr({ … })
.selectToAutocomplete()
.on('change', function(){ … });
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looking good, but the repetition of the
skip if `which tidy`.empty?
seems unnecessary and error-prone. I think it would be a lot cleaner and simpler to move that check inside the last_response_must_be_valid
check.
@tmtmtmtm feedback addressed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: this still seems like it's doing way too many things at once. Not being able to fix any of the problems until we've fixed all of the problems in a monster PR seems like completely the wrong approach.
class="person-card__image"> | ||
<noscript><img src="<%= person.proxy_image %>" class="person-card__image"></noscript> | ||
class="person-card__image" | ||
alt="Member headshot"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is a plain "Member headshot" sufficient, when there might be hundreds of these across the page? Perhaps we should include the member's name here?
<% else %> | ||
<img src="/images/person-placeholder-108px.png" class="person-card__image"> | ||
<img src="/images/person-placeholder-108px.png" class="person-card__image" | ||
alt="Placeholder image"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto here. "Placeholder image for Freddy McFreedy" seems like it might be more useful.
Firefox was showing the source code with the heading tags in red. I discovered that it was due to a missing link-closing tag, so I added to the main layout heading. But it is much better if we have an automated way to detect and correct those things. Hence this addition. The gem uses the tidy-html5 validator, which can be installed locally optionally.
I ran the validator against each page and did a separate commit for each, including the reported errors for that page.
@zarino , I had to remove some of your code (basically attributes in the main page's
select
) and add code on some other places (mostlyalt
attributes to images), so I would like you to take a look at this as well if you please.