Skip to content

Commit

Permalink
changing getNodeInfo to getNodeDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianaixba committed Sep 14, 2020
1 parent f18bb19 commit cda6169
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 51 deletions.
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/accessibility.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global window, document, getNodeInfo */
/* global window, document, getNodeDetails */

const Gatherer = require('./gatherer.js');
const fs = require('fs');
Expand Down Expand Up @@ -61,8 +61,8 @@ function runA11yChecks() {
// @ts-expect-error

result.nodes.forEach(node => {
// @ts-expect-error - getNodeInfo put into scope via stringification
Object.assign(node, getNodeInfo(node.element));
// @ts-expect-error - getNodeDetails put into scope via stringification
Object.assign(node, getNodeDetails(node.element));
// avoid circular JSON concerns
node.element = node.any = node.all = node.none = undefined;
});
Expand Down Expand Up @@ -101,7 +101,7 @@ class Accessibility extends Gatherer {
afterPass(passContext) {
const driver = passContext.driver;
const expression = `(function () {
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
${axeLibSource};
return (${runA11yChecks.toString()}());
})()`;
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/anchor-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global getNodeInfo */
/* global getNodeDetails */

const Gatherer = require('./gatherer.js');
const pageFunctions = require('../../lib/page-functions.js');
Expand Down Expand Up @@ -43,8 +43,8 @@ function collectAnchorElements() {
const anchorElements = getElementsInDocument('a'); // eslint-disable-line no-undef

return anchorElements.map(node => {
// @ts-expect-error - getNodeInfo put into scope via stringification
const nodeInfo = getNodeInfo(node);
// @ts-expect-error - getNodeDetails put into scope via stringification
const nodeInfo = getNodeDetails(node);
if (node instanceof HTMLAnchorElement) {
return {
href: node.href,
Expand Down Expand Up @@ -97,7 +97,7 @@ class AnchorElements extends Gatherer {
const driver = passContext.driver;
const expression = `(() => {
${pageFunctions.getElementsInDocumentString};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return (${collectAnchorElements})();
})()`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global document ClipboardEvent getNodeInfo */
/* global document ClipboardEvent getNodeDetails */

const Gatherer = require('../gatherer.js');
const pageFunctions = require('../../../lib/page-functions.js');
Expand All @@ -23,8 +23,8 @@ function findPasswordInputsWithPreventedPaste() {
)
)
.map(passwordInput => ({
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(passwordInput),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(passwordInput),
}));
}

Expand All @@ -35,7 +35,7 @@ class PasswordInputsWithPreventedPaste extends Gatherer {
*/
afterPass(passContext) {
const expression = `(() => {
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return (${findPasswordInputsWithPreventedPaste.toString()}());
})()`;

Expand Down
16 changes: 8 additions & 8 deletions lighthouse-core/gather/gatherers/form-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global getNodeInfo */
/* global getNodeDetails */

const Gatherer = require('./gatherer.js');
const pageFunctions = require('../../lib/page-functions.js');
Expand Down Expand Up @@ -39,8 +39,8 @@ function collectFormElements() {
id: parentFormElement.id,
name: parentFormElement.name,
autocomplete: parentFormElement.autocomplete,
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(parentFormElement),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(parentFormElement),
},
inputs: [],
labels: [],
Expand All @@ -60,15 +60,15 @@ function collectFormElements() {
attribute: child.getAttribute('autocomplete'),
prediction: child.getAttribute('autofill-prediction'),
},
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(child),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(child),
});
}
if (child instanceof HTMLLabelElement) {
formObj.labels.push({
for: child.htmlFor,
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(child),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(child),
});
}
}
Expand All @@ -92,7 +92,7 @@ class FormElements extends Gatherer {

const expression = `(() => {
${pageFunctions.getElementsInDocumentString};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return (${collectFormElements})();
})()`;

Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/iframe-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global getNodeInfo */
/* global getNodeDetails */

const Gatherer = require('./gatherer.js');
const pageFunctions = require('../../lib/page-functions.js');
Expand All @@ -28,8 +28,8 @@ function collectIFrameElements() {
clientRect: {top, bottom, left, right, width, height},
// @ts-expect-error - put into scope via stringification
isPositionFixed: isPositionFixed(node), // eslint-disable-line no-undef
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(node),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(node),
};
});
}
Expand All @@ -46,7 +46,7 @@ class IFrameElements extends Gatherer {
const expression = `(() => {
${pageFunctions.getElementsInDocumentString};
${pageFunctions.isPositionFixedString};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return (${collectIFrameElements})();
})()`;

Expand Down
12 changes: 6 additions & 6 deletions lighthouse-core/gather/gatherers/image-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const pageFunctions = require('../../lib/page-functions.js');
const Driver = require('../driver.js'); // eslint-disable-line no-unused-vars
const FontSize = require('./seo/font-size.js');

/* global window, getElementsInDocument, Image, getNodeInfo, ShadowRoot */
/* global window, getElementsInDocument, Image, getNodeDetails, ShadowRoot */


/** @param {Element} element */
Expand Down Expand Up @@ -86,8 +86,8 @@ function getHTMLImages(allElements) {
isInShadowDOM: element.getRootNode() instanceof ShadowRoot,
// https://html.spec.whatwg.org/multipage/images.html#pixel-density-descriptor
usesSrcSetDensityDescriptor: / \d+(\.\d+)?x/.test(element.srcset),
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(element),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(element),
};
});
}
Expand Down Expand Up @@ -137,8 +137,8 @@ function getCSSImages(allElements) {
),
usesSrcSetDensityDescriptor: false,
resourceSize: 0, // this will get overwritten below
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(element),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(element),
});
}

Expand Down Expand Up @@ -301,7 +301,7 @@ class ImageElements extends Gatherer {
const expression = `(function() {
${pageFunctions.getElementsInDocumentString}; // define function on page
${pageFunctions.getBoundingClientRectString};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
${getClientRect.toString()};
${getPosition.toString()};
${getHTMLImages.toString()};
Expand Down
11 changes: 4 additions & 7 deletions lighthouse-core/gather/gatherers/link-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ const LinkHeader = require('http-link-header');
const Gatherer = require('./gatherer.js');
const {URL} = require('../../lib/url-shim.js');
const NetworkAnalyzer = require('../../lib/dependency-graph/simulator/network-analyzer.js');
const {
getElementsInDocumentString,
getNodeInfoString,
} = require('../../lib/page-functions.js');
const {getElementsInDocumentString, getNodeDetailsString} = require('../../lib/page-functions.js');

/* globals HTMLLinkElement getNodeInfo */
/* globals HTMLLinkElement getNodeDetails */

/**
* @fileoverview
Expand Down Expand Up @@ -74,7 +71,7 @@ function getLinkElementsInDOM() {
hrefRaw,
source,
// @ts-expect-error - put into scope via stringification
...getNodeInfo(link),
...getNodeDetails(link),
});
}

Expand All @@ -92,7 +89,7 @@ class LinkElements extends Gatherer {
return passContext.driver.evaluateAsync(`(() => {
${getElementsInDocumentString};
${getLinkElementsInDOM};
${getNodeInfoString};
${getNodeDetailsString};
return getLinkElementsInDOM();
})()`, {useIsolation: true});
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/script-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const NetworkRequest = require('../../lib/network-request.js');
const getElementsInDocumentString = require('../../lib/page-functions.js').getElementsInDocumentString; // eslint-disable-line max-len
const pageFunctions = require('../../lib/page-functions.js');

/* global getNodeInfo */
/* global getNodeDetails */

/**
* @return {LH.Artifacts['ScriptElements']}
Expand All @@ -30,8 +30,8 @@ function collectAllScriptElements() {
async: script.async,
defer: script.defer,
source: /** @type {'head'|'body'} */ (script.closest('head') ? 'head' : 'body'),
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(script),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(script),
content: script.src ? null : script.text,
requestId: null,
};
Expand Down Expand Up @@ -75,7 +75,7 @@ class ScriptElements extends Gatherer {
/** @type {LH.Artifacts['ScriptElements']} */
const scripts = await driver.evaluateAsync(`(() => {
${getElementsInDocumentString}
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return (${collectAllScriptElements.toString()})();
})()`, {useIsolation: true});

Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/seo/tap-targets.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global document, window, getComputedStyle, getElementsInDocument, Node, getNodeInfo */
/* global document, window, getComputedStyle, getElementsInDocument, Node, getNodeDetails */

const Gatherer = require('../gatherer.js');
const pageFunctions = require('../../../lib/page-functions.js');
Expand Down Expand Up @@ -271,8 +271,8 @@ function gatherTapTargets() {
targets.push({
clientRects: visibleClientRects,
href: /** @type {HTMLAnchorElement} */(tapTargetElement)['href'] || '',
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(tapTargetElement),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(tapTargetElement),
});
}

Expand Down Expand Up @@ -301,7 +301,7 @@ class TapTargets extends Gatherer {
${getLargestRect.toString()};
${getRectCenterPoint.toString()};
${rectContains.toString()};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
${gatherTapTargets.toString()};
return gatherTapTargets();
Expand Down
8 changes: 4 additions & 4 deletions lighthouse-core/gather/gatherers/trace-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
'use strict';

/* global getNodeInfo */
/* global getNodeDetails */

/**
* @fileoverview
Expand All @@ -30,8 +30,8 @@ function getNodeDetailsData() {
let traceElement;
if (elem) {
traceElement = {
// @ts-expect-error - getNodeInfo put into scope via stringification
...getNodeInfo(elem),
// @ts-expect-error - getNodeDetails put into scope via stringification
...getNodeDetails(elem),
};
}
return traceElement;
Expand Down Expand Up @@ -282,7 +282,7 @@ class TraceElements extends Gatherer {
objectId,
functionDeclaration: `function () {
${getNodeDetailsData.toString()};
${pageFunctions.getNodeInfoString};
${pageFunctions.getNodeDetailsString};
return getNodeDetailsData.call(this);
}`,
returnByValue: true,
Expand Down
4 changes: 2 additions & 2 deletions lighthouse-core/lib/page-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ function wrapRequestIdleCallback(cpuSlowdownMultiplier) {
};
}

const getNodeInfoString = `function getNodeInfo(elem) {
const getNodeDetailsString = `function getNodeDetails(elem) {
${getNodePath.toString()};
${getNodeSelector.toString()};
${getBoundingClientRect.toString()};
Expand All @@ -444,7 +444,7 @@ module.exports = {
getOuterHTMLSnippet: getOuterHTMLSnippet,
computeBenchmarkIndex: computeBenchmarkIndex,
computeBenchmarkIndexString: computeBenchmarkIndex.toString(),
getNodeInfoString,
getNodeDetailsString,
getNodePathString: getNodePath.toString(),
getNodeSelectorString: getNodeSelector.toString(),
getNodeSelector: getNodeSelector,
Expand Down

0 comments on commit cda6169

Please sign in to comment.