diff --git a/plugins/embed-optimizer/detect.js b/plugins/embed-optimizer/detect.js index bb4a6fb620..9a5f93e71d 100644 --- a/plugins/embed-optimizer/detect.js +++ b/plugins/embed-optimizer/detect.js @@ -2,8 +2,8 @@ * Embed Optimizer module for Optimization Detective * * When a URL metric is being collected by Optimization Detective, this module adds a ResizeObserver to keep track of - * the changed heights for embed blocks. This data is amended onto the element data of the pending URL metric when it - * is submitted for storage. + * the changed heights for embed blocks. This data is extended/amended onto the element data of the pending URL metric + * when it is submitted for storage. */ const consoleLogPrefix = '[Embed Optimizer]'; @@ -16,7 +16,7 @@ const consoleLogPrefix = '[Embed Optimizer]'; * @typedef {import("../optimization-detective/types.d.ts").InitializeArgs} InitializeArgs * @typedef {import("../optimization-detective/types.d.ts").FinalizeArgs} FinalizeArgs * @typedef {import("../optimization-detective/types.d.ts").FinalizeCallback} FinalizeCallback - * @typedef {import("../optimization-detective/types.d.ts").AmendedElementData} AmendedElementData + * @typedef {import("../optimization-detective/types.d.ts").ExtendedElementData} ExtendedElementData */ /** @@ -76,11 +76,11 @@ export function initialize( { isDebug } ) { export async function finalize( { isDebug, getElementData, - amendElementData, + extendElementData, } ) { for ( const [ xpath, domRect ] of loadedElementContentRects.entries() ) { try { - amendElementData( xpath, { + extendElementData( xpath, { resizedBoundingClientRect: domRect, } ); if ( isDebug ) { @@ -94,7 +94,7 @@ export async function finalize( { } } catch ( err ) { error( - `Failed to amend ${ xpath } with resizedBoundingClientRect data:`, + `Failed to extend element data for ${ xpath } with resizedBoundingClientRect:`, domRect, err ); diff --git a/plugins/optimization-detective/detect.js b/plugins/optimization-detective/detect.js index e24cb5841c..3f04404118 100644 --- a/plugins/optimization-detective/detect.js +++ b/plugins/optimization-detective/detect.js @@ -4,8 +4,8 @@ * @typedef {import("./types.d.ts").URLMetric} URLMetric * @typedef {import("./types.d.ts").URLMetricGroupStatus} URLMetricGroupStatus * @typedef {import("./types.d.ts").Extension} Extension - * @typedef {import("./types.d.ts").AmendedRootData} AmendedRootData - * @typedef {import("./types.d.ts").AmendedElementData} AmendedElementData + * @typedef {import("./types.d.ts").ExtendedRootData} ExtendedRootData + * @typedef {import("./types.d.ts").ExtendedElementData} ExtendedElementData */ const win = window; @@ -138,7 +138,7 @@ let urlMetric; * Reserved root property keys. * * @see {URLMetric} - * @see {AmendedElementData} + * @see {ExtendedElementData} * @type {Set} */ const reservedRootPropertyKeys = new Set( [ 'url', 'viewport', 'elements' ] ); @@ -155,13 +155,11 @@ function getRootData() { } /** - * Amends root URL metric data. + * Extends root URL metric data. * - * @todo Would "extend" be better than "amend"? Or something else? - * - * @param {AmendedRootData} properties + * @param {ExtendedRootData} properties */ -function amendRootData( properties ) { +function extendRootData( properties ) { for ( const key of Object.getOwnPropertyNames( properties ) ) { if ( reservedRootPropertyKeys.has( key ) ) { throw new Error( `Disallowed setting of key '${ key }' on root.` ); @@ -181,7 +179,7 @@ const elementsByXPath = new Map(); * Reserved element property keys. * * @see {ElementData} - * @see {AmendedRootData} + * @see {ExtendedRootData} * @type {Set} */ const reservedElementPropertyKeys = new Set( [ @@ -210,12 +208,12 @@ function getElementData( xpath ) { } /** - * Amends element data. + * Extends element data. * - * @param {string} xpath XPath. - * @param {AmendedElementData} properties Properties. + * @param {string} xpath XPath. + * @param {ExtendedElementData} properties Properties. */ -function amendElementData( xpath, properties ) { +function extendElementData( xpath, properties ) { if ( ! elementsByXPath.has( xpath ) ) { throw new Error( `Unknown element with XPath: ${ xpath }` ); } @@ -529,8 +527,8 @@ export default async function detect( { isDebug, getRootData, getElementData, - amendElementData, - amendRootData, + extendElementData, + extendRootData, } ); } catch ( err ) { error( diff --git a/plugins/optimization-detective/types.d.ts b/plugins/optimization-detective/types.d.ts index 7668e97eb1..50b36356f8 100644 --- a/plugins/optimization-detective/types.d.ts +++ b/plugins/optimization-detective/types.d.ts @@ -11,7 +11,7 @@ export interface ElementData { boundingClientRect: DOMRectReadOnly; } -export type AmendedElementData = ExcludeProps +export type ExtendedElementData = ExcludeProps export interface URLMetric { url: string; @@ -22,7 +22,7 @@ export interface URLMetric { elements: ElementData[]; } -export type AmendedRootData = ExcludeProps +export type ExtendedRootData = ExcludeProps export interface URLMetricGroupStatus { minimumViewportWidth: number; @@ -37,9 +37,9 @@ export type InitializeCallback = ( args: InitializeArgs ) => void; export type FinalizeArgs = { readonly getRootData: () => URLMetric, - readonly amendRootData: ( properties: AmendedRootData ) => void, + readonly extendRootData: ( properties: ExtendedRootData ) => void, readonly getElementData: ( xpath: string ) => ElementData|null, - readonly amendElementData: ( xpath: string, properties: AmendedElementData ) => void, + readonly extendElementData: (xpath: string, properties: ExtendedElementData ) => void, readonly isDebug: boolean, };