Skip to content

Commit

Permalink
Rename type to metricTag
Browse files Browse the repository at this point in the history
  • Loading branch information
Beytoven committed Apr 2, 2020
1 parent e05c36f commit 597c071
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
2 changes: 1 addition & 1 deletion lighthouse-core/audits/metrics/largest-contentful-paint.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class LargestContentfulPaint extends Audit {
* @return {LH.Audit.Details.Table['items']}
*/
static getNodeData(traceNodes) {
const lcpNode = traceNodes.find(node => node.type === 'lcp');
const lcpNode = traceNodes.find(node => node.metricTag === 'lcp');
if (!lcpNode) {
return [];
}
Expand Down
13 changes: 0 additions & 13 deletions lighthouse-core/gather/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -1237,19 +1237,6 @@ class Driver {
return flattenedDocument.nodes ? flattenedDocument.nodes : [];
}

/**
* @param {number} nodeId
* @param {string} attributeName
* @param {string} attributeValue
*/
async setNodeAttribute(nodeId, attributeName, attributeValue) {
await this.sendCommand('DOM.setAttributeValue', {
nodeId: nodeId,
name: attributeName,
value: attributeValue,
});
}

/**
* @param {{x: number, y: number}} position
* @return {Promise<void>}
Expand Down
8 changes: 6 additions & 2 deletions lighthouse-core/gather/gatherers/trace-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function collectTraceNodes() {

for (const element of markedElements) {
traceNodes.push({
type: element.getAttribute('lhtemp') || '',
metricTag: element.getAttribute('lhtemp') || '',
// @ts-ignore - put into scope via stringification
nodePath: getNodePath(element), // eslint-disable-line no-undef
// @ts-ignore - put into scope via stringification
Expand Down Expand Up @@ -56,7 +56,11 @@ class TraceNodes extends Gatherer {
await driver.sendCommand('DOM.getDocument', {depth: -1, pierce: true});
const translatedIds = await driver.sendCommand('DOM.pushNodesByBackendIdsToFrontend',
{backendNodeIds: [backendNodeId]});
driver.setNodeAttribute(translatedIds.nodeIds[0], 'lhtemp', 'lcp');
await driver.sendCommand('DOM.setAttributeValue', {
nodeId: translatedIds.nodeIds[0],
name: 'lhtemp',
value: 'lcp',
});
}

const expression = `(() => {
Expand Down
2 changes: 1 addition & 1 deletion types/artifacts.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ declare global {
}

export interface TraceNode {
type: string;
metricTag: string;
selector: string;
nodeLabel?: string;
nodePath: string;
Expand Down

0 comments on commit 597c071

Please sign in to comment.