-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent JavaScript component config being flattened #4230
Labels
accordion
🐛 bug
Something isn't working the way it should (including incorrect wording in documentation)
button
character count
error summary
exit this page
javascript
notification banner
Milestone
Comments
colinrotherham
added
🐛 bug
Something isn't working the way it should (including incorrect wording in documentation)
button
javascript
character count
accordion
error summary
notification banner
exit this page
labels
Sep 19, 2023
To avoid confusion, we should distinguish Then we may want to clearly flatten and extract only i18n key/values as shown: this.config = mergeConfigs(Accordion.defaults, config)
// Component data attributes
const dataset = normaliseDataset($module.dataset)
// Flatten i18n config property only
this.config.i18n = extractConfigByNamespace(
flattenConfigs(this.config, dataset),
'i18n'
)
this.i18n = new I18n(this.config.i18n) Additional dataset propertiesNotice the untyped config property We may want to assign only known dataset values rather than merging them all const dataset = normaliseDataset($module.dataset)
// Add known values only
this.config.AAA = dataset.AAA
this.config.BBB = dataset.BBB
this.config.CCC = dataset.CCC |
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
colinrotherham
added a commit
that referenced
this issue
Feb 23, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Feb 27, 2024
colinrotherham
added a commit
that referenced
this issue
Feb 27, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Mar 7, 2024
colinrotherham
added a commit
that referenced
this issue
Mar 7, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Mar 8, 2024
This prevents unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Mar 8, 2024
Since we only pass in `DOMStringMap` values, this removes all tests for `normaliseDataset()` that don’t pass in strings We also prevent unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
colinrotherham
added a commit
that referenced
this issue
Mar 8, 2024
Since we only pass in `DOMStringMap` values, this removes all tests for `normaliseDataset()` that don’t pass in strings We also prevent unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
owenatgov
pushed a commit
that referenced
this issue
Apr 4, 2024
owenatgov
pushed a commit
that referenced
this issue
Apr 4, 2024
Since we only pass in `DOMStringMap` values, this removes all tests for `normaliseDataset()` that don’t pass in strings We also prevent unnecessary data attributes (e.g. `data-module="govuk-accordion"’) from being merged into the config See: #4230
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
accordion
🐛 bug
Something isn't working the way it should (including incorrect wording in documentation)
button
character count
error summary
exit this page
javascript
notification banner
Description of the issue
Our JavaScript component configs are being flattened in
mergeConfigs()
and don't match JSDoc outputSteps to reproduce the issue
Instantiate a component (e.g. Accordion) using the JavaScript API
Before
Console output for
Accordion.defaults
shows an unflattened configAfter
Console output for
new Accordion().config
shows an unexpectedly flattened configBoth are accidentally typed with
AccordionConfig
even though they're differentActual vs expected behaviour
Whilst we've picked "flattening" to our method to normalise
i18n
text betweendata-*
attributes and the JavaScript API, the final mergednew Accordion().config
is expected to match the JavaScript API format in JSDoc output.We hold our JavaScript component configs in two places:
Accordion.defaults
new Accordion().config
We merge component config
data-*
attributes over JavaScript config, using the defaults to fill the gapsThe text was updated successfully, but these errors were encountered: