Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
report: make urls clickable
  • Loading branch information
connorjclark committed Jun 17, 2019
commit aa94dee2cc754a84a555a731e2e40832ab7be1be
15 changes: 14 additions & 1 deletion lighthouse-core/report/html/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.


if (displayedHost) {
const hostElem = this._renderText(displayedHost);
Expand Down Expand Up @@ -160,6 +160,19 @@ class DetailsRenderer {
return element;
}

/**
* @param {string} text
* @param {string} href
* @return {Element}
*/
_renderAnchor(text, href) {
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 ;)

return element;
}

/**
* @param {string} text
* @return {Element}
Expand Down
5 changes: 5 additions & 0 deletions lighthouse-core/report/html/report-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,11 @@
object-fit: contain;
}

a.lh-anchor {
color: inherit;
text-decoration: none;
}

/* Chevron
https://codepen.io/paulirish/pen/LmzEmK
*/
Expand Down