report: source-location for linkifying#9354
Conversation
patrickhulce
left a comment
There was a problem hiding this comment.
this is awesome!! a few concerns with the new attribution method, but I think this approach puts us in a much better place to be able to handle those challenges 👍
can we deal with these separately? They seem related but with significantly different concerns (audit internals vs report rendering/devtools integration) |
Done! #9356 |
| element.classList.add('lh-source-location'); | ||
| element.setAttribute('data-url', item.url); | ||
| // Should pass `line` to `data-line` as zero-indexed, as DevTools expects that for linkifying. | ||
| element.setAttribute('data-line', String(item.line)); |
There was a problem hiding this comment.
i think .toString() is a little favored over using the constructor.
There was a problem hiding this comment.
fyi this file uses String() a few times but never toString
There was a problem hiding this comment.
fyi this file uses
String()a few times but nevertoString
yeah, I don't know how that happened in here but generally good to stick with the ambient style
There was a problem hiding this comment.
changed to toString()
note, if a plugin happens to provide a bad value (or no value) here, it would now error the renderer.
There was a problem hiding this comment.
Sorry, I was agreeing with you that String() is fine in here since it's the established style
(there's only so much we can do against a plugin that refuses to use our types, though. you don't even need a plugin, you could just save a bad lhr to a gist and load it in the viewer)
There was a problem hiding this comment.
oops, reverted.
| * @protected | ||
| */ | ||
| renderSourceLocation(item) { | ||
| if (!item.url) { |
There was a problem hiding this comment.
this shouldn't be possible now with the changes to make url required, right?
There was a problem hiding this comment.
I'm guarding against an empty string here. Perhaps that's not necessary, and just allowing the url to be meaningless is better than showing nothing.
It may be possible to get an empty string from stylesheet.sourceURL if it came from a comment - I'd have to check. It is certainly possible for a plugin to provide an empty string.
| } | ||
|
|
||
| element.classList.add('lh-source-location'); | ||
| element.setAttribute('data-url', item.url); |
There was a problem hiding this comment.
already done in renderTextURL?
There was a problem hiding this comment.
oh, didn't see dataset.url =
There is a difference - renderTextURL only sets the url if it is a valid URL. However, we can expect a sourceURL to not be a valid URL, yet it is still needed to resolve correctly with the devtools front end (it know about styles.css if there was a magic comment defining it, even if it isn't a full url).
maybe this should be data-source-url and data-source-line? would also prevent clash with the 3p filter.
|
|
||
| const deprecations = entries.filter(log => log.entry.source === 'deprecation').map(log => { | ||
| // HTML deprecations will have no url and no way to attribute to a specific line. | ||
| let source = null; |
There was a problem hiding this comment.
undefined should work (and hopefully allows getting rid of the null mentioned in another comment)
Co-Authored-By: Brendan Kenny <bckenny@gmail.com>
This reverts commit 30a7daf.
| }, | ||
| { | ||
| "source": "deprecation", | ||
| "value": "/deep/ combinator is no longer supported in CSS dynamic profile.It is now effectively no-op, acting as if it were a descendant combinator. /deep/ combinator will be removed, and will be invalid at M65. You should remove it. See https://www.chromestatus.com/features/4964279606312960 for more details." |
There was a problem hiding this comment.
this message is missing a space so i fixed it: https://chromium-review.googlesource.com/c/chromium/src/+/1790201
|
@brendankenny can you take a look |
|
@brendankenny we're gonna merge tomorrow, FYI |
Linkify source code in DevTools.
Fixes: #6436, second half of #5443,
I've done
font-sizehere. I haven't explored what other audits this could be done for.font-sizeonly applies to CSS, but the changes here should be sufficient for JS/HTML too.I've also made the line/columns that
font-sizereports more accurate. Namely:startColumnwas always being add to the rule's column. However, this is only valid if the stylesheet and the rule begin on the same line in the HTML.{url: <source mapped url>, line: <line relative to script tag>, column: <ditto>}is necessary for DevTools to link to this file in the Source panel, so without this change that gets complicated.LH report (outside DevTools) before/after ...
Before:
After:
http://misc-hoten.surge.sh/lh-reports/pr-9354.html

GIF of it working in DevTools:
Associated Chromium changes: https://chromium-review.googlesource.com/c/chromium/src/+/1694144
Test it out: