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

Report: Fix HTML validation errors. #1575

Merged
merged 2 commits into from
Feb 1, 2017
Merged

Report: Fix HTML validation errors. #1575

merged 2 commits into from
Feb 1, 2017

Conversation

XhmikosR
Copy link
Contributor

@XhmikosR XhmikosR commented Jan 29, 2017

BTW, this fixes a 404 link along the way (the link with the double quotes).

@@ -56,7 +56,7 @@ class ReportGenerator {

// Converts a name to a link.
Handlebars.registerHelper('nameToLink', name => {
return name.toLowerCase().replace(/\s/, '-');
return name.toLowerCase().replace(/\s/g, '-');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is self-explanatory for me but just in case it isn't, say the name is Progressive Web app. Previously it became progressive-web app which is invalid.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp. mind attending a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where and how; I haven't looked into tests yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be enough in /lighthouse-core/test/report/report-test.js

  it('`nameToLink` works properly', () => {
    const reportGenerator = new ReportGenerator();
    const html = reportGenerator.generateHTML(sampleResults);
    assert.ok(/href="#progressive-web-app"/gm.test(html));
  });

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, that's probably best for now. We really don't have a great way to test the registered handlebar helpers atm. The few tests we have, look at the generated output :\

Maybe make the asset more specific so there is a smaller chance of false positives in the future. We want make sure "progressive-web-app" is from the nameToLink output and not something else. There's also another place to check:

assert.ok(/class="menu__link" href="#progressive-web-app"/gm.test(html));
assert.ok(/id="progressive-web-app"/gm.test(html));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also make the helpers static (and private) functions so they're testable on their own. It would make the tests a little easier to write and run a little faster.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You beat me to it :) #1581

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Jan 30, 2017

The only 2 things left are:

  1. Report: move all CSS to head #1578
  2. I'd specify the HTML lang="en" but being that is being used twice in tests I left it out. I could apply it if you guys agree, though.

Copy link
Contributor

@ebidel ebidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff. Just the test if you can add it.

@@ -2,6 +2,7 @@
.table_list {
margin-top: 8px;
border: 1px solid #EBEBEB;
border-spacing: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -56,7 +56,7 @@ class ReportGenerator {

// Converts a name to a link.
Handlebars.registerHelper('nameToLink', name => {
return name.toLowerCase().replace(/\s/, '-');
return name.toLowerCase().replace(/\s/g, '-');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

derp. mind attending a test for this?

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@ebidel
Copy link
Contributor

ebidel commented Feb 1, 2017

Rebased for ya :)

@googlebot
Copy link

CLAs look good, thanks!

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Feb 1, 2017

Rebased, should be OK now. Only the Element style not allowed as child of element li in this context. errors are left.

Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't support the use of html validators as a rule, but these changes LGTM :)

@brendankenny brendankenny merged commit 7117029 into GoogleChrome:master Feb 1, 2017
@XhmikosR XhmikosR deleted the report-validation-fixes branch February 1, 2017 23:51
@XhmikosR
Copy link
Contributor Author

XhmikosR commented Feb 1, 2017

I wouldn't have caught the 2 issues, one with the 404 link and the second with the spaces in the anchors if it weren't for the validator.

IMO it's a good safety measure to have it run and be HTML valid as close as possible :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants