Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
colinrotherham committed Feb 3, 2025
1 parent bbfb2ba commit ab3d188
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/govuk-frontend/src/govuk/common/configuration.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function normaliseString(value, property) {
*
* @internal
* @template {Partial<Record<keyof ConfigurationType, unknown>>} ConfigurationType
* @template {[keyof ConfigurationType, SchemaProperty | undefined][]} SchemaEntryType
* @param {{ schema?: Schema<ConfigurationType>, moduleName: string }} Component - Component class
* @param {DOMStringMap} dataset - HTML element dataset
* @returns {ObjectNested} Normalised dataset
Expand All @@ -163,13 +164,16 @@ export function normaliseDataset(Component, dataset) {
)
}

const out = /** @type {ReturnType<typeof normaliseDataset>} */ ({})
const out = /** @type {ObjectNested} */ ({})
const entries = /** @type {SchemaEntryType} */ (
Object.entries(Component.schema.properties)
)

// Normalise top-level dataset ('data-*') values using schema types
for (const entries of /** @type {[keyof ConfigurationType, SchemaProperty | undefined][]} */ (
Object.entries(Component.schema.properties)
)) {
const [namespace, property] = entries
for (const entry of entries) {
const [namespace, property] = entry

// Cast the `namespace` to string so it can be used to access the dataset
const field = namespace.toString()

if (field in dataset) {
Expand Down

0 comments on commit ab3d188

Please sign in to comment.