-
Notifications
You must be signed in to change notification settings - Fork 21
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
Update module.js
ready for v5 of govuk-frontend
#3992
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
April 24, 2024 07:57
8e66272
to
2b5c083
Compare
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 15, 2024 09:30
a040d7e
to
0cf57d3
Compare
MartinJJones
changed the title
Update
Update May 15, 2024
module.js
approach ready for v5 of govuk-frontendmodule.js
ready for v5 of govuk-frontend
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 15, 2024 14:03
0cf57d3
to
991972b
Compare
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 15, 2024 14:04
991972b
to
655059b
Compare
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 17, 2024 08:59
48971de
to
3947e2d
Compare
andysellick
reviewed
May 17, 2024
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 17, 2024 10:15
3947e2d
to
8741fef
Compare
andysellick
approved these changes
May 17, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work. Personally I'd merge the two commits together as they relate directly to each other.
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 17, 2024 10:36
8741fef
to
4506753
Compare
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 21, 2024 08:51
4506753
to
45aab2d
Compare
- Update the start function in `module.js` to support how JS modules are initialisted in govuk-frontend v5 as initialisation now happens automatically - see "Remove calls to component init methods from your JavaScript" in the release notes of [GOV.UK Frontend v5.0.0](https://github.com/alphagov/govuk-frontend/releases/tag/v5.0.0) - Add tests to `modules.spec.js` to check modules are initialised as expected when the `init` method is not present - Update CHANGELOG.md
MartinJJones
force-pushed
the
update-js-approach-ready-for-v5
branch
from
May 21, 2024 08:52
45aab2d
to
04a3f96
Compare
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
module.js
to support how JS modules are initialisted in govuk-frontend v5 as initialisation now happens automaticallymodules.spec.js
to check modules are initialised as expected when theinit
method is not on the modules prototypeWhy
Trello card
These changes are required to support v5 of govuk-frontend, by making these changes in advance of the release of v5 of govuk-frontend we can help avoid any potentially breaking changes when migrating to the new version of the gem that upgrades govuk-frontend to v5.
The main challenge here is when using static and frontend rendering applications. Modules are found and started in dependencies.js by including ./modules.js, this is called by static once for all applications on GOV.UK. If we were to include the changes made to
modules.js
as part of the upgrade to v5, this could cause some breaking changes in certain scenarios, further examples below.Accordion Component
Scenario
collections
is running v5 of govuk-frontendstatic
is running an old version of the gem that does not support both initialisation approaches inmodules.js
Outcome
As the
init
method is removed from the accordion component in v5 of govuk-frontend, the accordion component from govuk-frontend will not be initialised inmodules.js
Impact
The content will not be accessible as shown in the screenshots below. This is a known issue and further details are included in alphagov/govuk-frontend#999
Tabs Component
Scenario
frontend
is running v5 of govuk-frontendstatic
is running an old version of the gem that does not support both initialisation approaches inmodules.js
Outcome
As the
init
method is removed from the tabs component in v5 of govuk-frontend, the tabs component from govuk-frontend will not be initialised inmodules.js
Impact
Further information