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: make urls clickable #9224

Merged
merged 18 commits into from
Jun 29, 2019
Merged

report: make urls clickable #9224

merged 18 commits into from
Jun 29, 2019

Conversation

connorjclark
Copy link
Collaborator

URLs in tables and in the critical request chain details are now clickable.

NYT: https://misc-hoten.surge.sh/www.nytimes.com_2019-06-17_11-40-25.report.html

See #5443

@@ -113,7 +113,7 @@ class DetailsRenderer {
}

const element = this._dom.createElement('div', 'lh-text__url');
element.appendChild(this._renderText(displayedPath));
element.appendChild(this._renderAnchor(displayedPath, url));
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems like we should rename this method now ;)

maybe we can also share some logic with renderLink at this point since I was about to make _renderAnchor comments about falling back to text on invalid, etc

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ah, didn't see that method. done.

lighthouse-core/report/html/report-styles.css Show resolved Hide resolved
const element = this._dom.createElement('a', 'lh-anchor');
element.textContent = text;
element.href = href;
element.target = '_blank';
Copy link
Collaborator

Choose a reason for hiding this comment

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

don't forget rel=noopener ;)

@@ -113,7 +113,7 @@ class DetailsRenderer {
}

const element = this._dom.createElement('div', 'lh-text__url');
element.appendChild(this._renderText(displayedPath));
element.appendChild(this._renderLink(displayedPath, new URL(url)));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to move the URL construction out of _renderLink, since that's the error-prone step @patrickhulce was running into and is adding the guard against in #9067.

Can be

Suggested change
element.appendChild(this._renderLink(displayedPath, new URL(url)));
element.appendChild(this._renderLink({text: displayedPath, url}));

lighthouse-core/report/html/report-styles.css Show resolved Hide resolved
@@ -769,9 +769,8 @@

</span>
<span class="crc-node__tree-value">
<span class="crc-node__tree-file"><!-- fill me: node.request.url.file --></span>
<a class="lh-link crc-node__tree-file" target="_blank"><!-- fill me: node.request.url.file --></a>
Copy link
Member

Choose a reason for hiding this comment

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

obviously we do need to run lighthouse against itself, also need noopener here :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

one day :)

Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

Copy link
Member

@paulirish paulirish 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 think we should apply a text-decoration on hover if it's not linked.. I started looking into why that happens and then #9237 happened.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.


.lh-text__url > .lh-text, .lh-text__url-host {
.lh-text__url-host {
display: inline;
Copy link
Member

Choose a reason for hiding this comment

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

@paulirish why is this a div in the first place then?

@@ -385,7 +385,7 @@ describe('DetailsRenderer', () => {
assert.equal(urlEl.localName, 'div');
assert.equal(urlEl.title, urlText);
assert.equal(urlEl.dataset.url, urlText);
assert.ok(urlEl.firstChild.classList.contains('lh-text'));
assert.equal(urlEl.firstChild.nodeName, 'A');
Copy link
Member

Choose a reason for hiding this comment

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

can you expand the tests of this anchor (here and below) now that it's more than just an .lh-text with the url? Can probably c/p from the renders link values test (though that doesn't appear to check the .lh-text__url-host stuff?)

assert.equal(chains[1].querySelector('.crc-node__tree-file').textContent, '/b.js');
assert.equal(chains[1].querySelector('.crc-node__tree-hostname').textContent, '(example.com)');
assert.equal(chains[1].querySelector('.lh-text__url a').textContent, '/b.js');
assert.equal(chains[1].querySelector('.lh-text__url-host').textContent, '(example.com)');
Copy link
Member

Choose a reason for hiding this comment

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

these tests should also be expanded

@@ -120,10 +121,10 @@ class CriticalRequestChainRenderer {
}

// Fill in url, host, and request size information.
const {file, hostname} = Util.parseURL(segment.node.request.url);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tests are failing b/c of this change. DetailsRenderer.renderTextURL tosses the host part if parsed.file === '/'. Before, the chain renderer always used the results of Util.parseURL w/o post-processing. The chain renderer now looks like this when run on the root url of a site:

image

before:

image

Copy link
Member

Choose a reason for hiding this comment

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

The chain renderer now looks like this when run on the root url of a site:

this is an improvement, IMO.

@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM!

@paulirish FYI I think your review has been addressed now that your PR has been merged

}

return dom.find('.lh-crc-container', tmpl);
}
}

// Alias b/c the name is really long.
Copy link
Collaborator

Choose a reason for hiding this comment

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

😆 this is great

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and have the pull request author add another comment and the bot will run again. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@connorjclark
Copy link
Collaborator Author

any further change requests? @brendankenny @paulirish

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

Successfully merging this pull request may close these issues.

5 participants