core: normalize creation of NodeValue#11877
Conversation
this is the bounding rect for all of the client rects of the tap target, plus some extra: lighthouse/lighthouse-core/lib/rect-helpers.js Lines 96 to 127 in d584194 not really the same as all the other bounding rects, the danger of trying to unify things in one type :) |
brendankenny
left a comment
There was a problem hiding this comment.
nice! Will definitely make it easier to make things real NodeValues
| lhId, | ||
| devtoolsNodePath: getNodePath(element), | ||
| selector: getNodeSelector(htmlElement), | ||
| devtoolsNodePath: getNodePath(element) || '', |
There was a problem hiding this comment.
maybe the fallbacks (if needed) should go in the individual functions rather than here?
Sure, let's split out the changes to |
| snippet: axeNode.node.snippet, | ||
| boundingRect: axeNode.node.boundingRect, | ||
| ...Audit.makeNodeValue(axeNode.node), | ||
| explanation: axeNode.failureSummary, |
There was a problem hiding this comment.
Doesn't look like this gets included in the report 🤔 . Is it supposed to?
| snippet: axeNode.node.snippet, | ||
| boundingRect: axeNode.node.boundingRect, | ||
| ...Audit.makeNodeValue(axeNode.node), | ||
| explanation: axeNode.failureSummary, |
There was a problem hiding this comment.
Why do we add
explanationhere?
| boundingRect?: Artifacts.Rect; | ||
| /** An HTML snippet used to identify the node. */ | ||
| snippet?: string; | ||
| snippet: string; |
There was a problem hiding this comment.
the possible bugs should be relatively minor, but unless we update snippet to always be a string in Util.prepareReportResult, this won't be typesafe for old LHRs (and if we have to retain the current if (item.snippet) { instead, there's not much benefit of making this non-optional)
| source: { | ||
| type: /** @type {'node'} */ ('node'), | ||
| ...Audit.makeNodeItem(plugin.node), | ||
| snippet: `<${tagName}${attributes}>${params}</${tagName}>`, |
There was a problem hiding this comment.
this ends up rendering completely differently in the report (it was basically just <span class="lh-node"><div class="lh-node__snippet">${snippet}</div></span> before). Does it work well for this audit (with these sometimes very long snippets)? Should it use the default NodeDetails snippet instead of its custom one?
There was a problem hiding this comment.
sometimes very long snippets
examples?
There was a problem hiding this comment.
Should it use the default NodeDetails snippet instead of its custom one?
Maybe, if we wanted to we could parameterize getNodeDetails/Snippet to accept a list of attribute names (give it SOURCE_PARAMS).
There was a problem hiding this comment.
Does it work well for this audit (with these sometimes very long snippets)?
examples?
unlike the getNodeDetails().snippet, the plugin attributes and params aren't ever truncated in number or string length, so it could be as long as the original page wanted
Should it use the default NodeDetails snippet instead of its custom one?
Maybe, if we wanted to we could parameterize
getNodeDetails/Snippetto accept a list of attribute names (give itSOURCE_PARAMS).
yeah, though I guess do we care about the <param> elements or are the element attributes (plus all the other node details stuff) sufficient to identify it?
There was a problem hiding this comment.
ehhh let's just use the default snippet so we can keep this simple. it'll be more identifiable now with the devtools node path and everything else, and truncation will prevent the worse cases.
| path: target.node.devtoolsNodePath, | ||
| selector: target.node.selector, | ||
| ...Audit.makeNodeItem(target.node), | ||
| boundingRect, |
There was a problem hiding this comment.
Which boundingRect should be used here? Using the boundingRect of all clientRects goes back to the first commit of #10716, but getNodeDetails also didn't exist back then, so that might have just been the most convenient way to do it at the time. Should it be the just node.boundingRect? When can the two differ? getBoundingClientRect should normally contain all child rects, but does it ever differ (transforms or something?)
There was a problem hiding this comment.
I'll followup with this in a different PR.
| [{ | ||
| tagName: 'APPLET', | ||
| params: [], | ||
| node: {}, |
There was a problem hiding this comment.
since this PR is adding a new EmbeddedContent artifact property and changing the audit details almost completely and we're trying to reach toward a typed test future (#11728), can these be generated so they're more like the real thing and the output tested to some degree?
There was a problem hiding this comment.
I'm struggling to find any actual pages with these elements. The one I found isn't included in our plugin list: https://www.quackit.com/html_5/tags/html_object_tag.cfm (video/quicktime). Should that type be included?
EDIT: well video/quicktime is expected to pass in a test. I don't understand the purpose of this audit if a quicktime plugin is acceptable. Is the idea that any video is OK? I suppose since this is an SEO audit video is out of scope, it's just that this audit also could double as a user/compat/browser-friendliness check.
Co-authored-by: Adam Raine <6752989+adamraine@users.noreply.github.com>
… into node-details-yay
Background
node: NodeDetailsproperty.NodeValueandNodeDetailsdiffer trivially:NodeDetails['devtoolsNodePath']is calledNodeValue['path']NodeDetailsonly optional fields arelhIdandboundingRect. InNodeValue, everything is optional.NodeDetailsare created by using the page functiongetNodeDetails.NodeValueby using aNodeDetails, but some audits create their ownNodeValuewithout the backing of aNodeDetails. These few non-standard usages is what forces us to haveNodeValuebe all-optional.(the following categories are not mutually exclusive)
A) Audits that create a
NodeValuedirectly from aNodeDetail(1:1)B) Audits that create a
NodeValuedirectly from aNodeDetail(but misses something. All of these are at least missingboundingRect/lhId, so no element screenshots):C) Audits that create a
NodeValuedirectly from aNodeDetail, but override a propertylighthouse/lighthouse-core/audits/seo/tap-targets.js
Line 256 in 2bdf6cb
D) Audits that create a
NodeValuefrom something OTHER than aNodeDetailfont-size(lighthouse/lighthouse-core/audits/seo/font-size.js
Line 120 in 2bdf6cb
hreflang(sometimes, only ifLinkElementis from response headers)This PR
NodeValuefrom aNodeDetails, use new functionAudit.makeNodeValue. This simplifies category A), fixes category B), and makes category C) much more obvious.snippetrequired inNodeValue. This is the strictest we can get with this, without changing anything about usages in category D). It also conceptually make sense... if you want to show something as anode, but aren't usingNodeDetails, you should be able to provide something HTML-ish.NodeDetailsare created via the page function, and that function always returnslhIdandboundingRect, we can make those properties required. This didn't require any code changes, I think it was an oversight in core(full-page-screenshot): resolve node rects during emulation #11536.To be extra sure thatNodeDetailsproperties are all present, for the string values do... || ''. I'm not super convinced about this (and it seems we'd really want to wrap each with atry...catchto catch the errors we've seen before).