Skip to content

Commit

Permalink
Merge pull request #3409 from alphagov/type-module-changes
Browse files Browse the repository at this point in the history
Use type=module for application.js
  • Loading branch information
AshGDS authored Aug 15, 2024
2 parents a34587f + 9cc9d21 commit 47146d8
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ GEM
govuk_personalisation (0.16.0)
plek (>= 1.9.0)
rails (>= 6, < 8)
govuk_publishing_components (41.1.1)
govuk_publishing_components (42.0.0)
govuk_app_config
govuk_personalisation (>= 0.7.0)
kramdown
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/analytics-ga4/ga4-finder-tracker.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//= require govuk_publishing_components/vendor/polyfills-govuk-frontend-v4/Element/prototype/closest.js
;(function (global) {
'use strict'

Expand Down
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/_expander.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
}

.js-enabled {
.govuk-frontend-supported {
.app-c-expander__heading {
position: relative;
padding: 10px 8px 5px 43px;
Expand Down
6 changes: 3 additions & 3 deletions app/assets/stylesheets/components/_mobile-filters.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
.app-mobile-filters-link {
display: none;

.js-enabled & {
.govuk-frontend-supported & {
display: inline-block;
margin-left: govuk-spacing(3);
margin-bottom: govuk-spacing(4);
Expand Down Expand Up @@ -40,7 +40,7 @@

// facet container should be hidden on mobile if
// javascript is available
.js-enabled .facets {
.govuk-frontend-supported .facets {
@include govuk-media-query($until: tablet) {
display: none;

Expand Down Expand Up @@ -70,7 +70,7 @@
// all filter styles are applicable on mobile only
// and when javascript is enabled
@include govuk-media-query($until: tablet) {
.js-enabled {
.govuk-frontend-supported {
.facets__box {
border-left: 5px solid #b1b4b6;
padding-left: govuk-spacing(2);
Expand Down
8 changes: 4 additions & 4 deletions app/assets/stylesheets/finder_frontend.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mark {
.filter-form {
position: relative;

.js-enabled & .button__wrapper {
.govuk-frontend-supported & .button__wrapper {
display: none;
}

Expand Down Expand Up @@ -201,7 +201,7 @@ mark {
border-radius: govuk-em(5, 16px);
background-color: govuk-colour("light-grey");

.js-enabled & {
.govuk-frontend-supported & {
padding: govuk-em(8, 16px) govuk-em(8, 16px) govuk-em(8, 16px) govuk-em(24, 16px);
}
}
Expand All @@ -213,7 +213,7 @@ mark {
position: relative;
z-index: 1;

.js-enabled & {
.govuk-frontend-supported & {
margin-left: govuk-em(5, 16px);
}
}
Expand All @@ -236,7 +236,7 @@ mark {
background: none;
border: 0;

.js-enabled & {
.govuk-frontend-supported & {
display: inline-block;
border: 1px solid transparent;

Expand Down
20 changes: 11 additions & 9 deletions app/views/development/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<% content_for :title, "Finder Frontend" %>

<%= render "govuk_publishing_components/components/title", title: "Finder Frontend" %>
<div id="content">
<%= render "govuk_publishing_components/components/title", title: "Finder Frontend" %>
<%= render "govuk_publishing_components/components/govspeak" do %>
<p>This page is only visible in development and Heroku.</p>
<%= render "govuk_publishing_components/components/govspeak" do %>
<p>This page is only visible in development and Heroku.</p>

<p>The following pages are rendered by this application:</p>
<p>The following pages are rendered by this application:</p>

<ul>
<% @rendered_pages.each do |page| %>
<li><%= link_to page.fetch("title"), page.fetch("link") %></li>
<ul>
<% @rendered_pages.each do |page| %>
<li><%= link_to page.fetch("title"), page.fetch("link") %></li>
<% end %>
</ul>
<% end %>
</ul>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/layouts/development_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<%=
render_component_stylesheets
%>
<%= javascript_include_tag "application", integrity: false %>
<%= javascript_include_tag "application", integrity: false, type: "module" %>
<%= javascript_include_tag 'es6-components', integrity: false, type: "module" %>
<meta name="robots" content="noindex">
</head>
Expand Down
4 changes: 2 additions & 2 deletions app/views/layouts/finder_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<%=
render_component_stylesheets
%>
<%= javascript_include_tag 'test-dependencies.js' if Rails.env.test? %>
<%= javascript_include_tag 'application', integrity: false %>
<%= javascript_include_tag 'test-dependencies.js', type: "module" if Rails.env.test? %>
<%= javascript_include_tag 'application', integrity: false, type: "module" %>
<%= javascript_include_tag 'es6-components', integrity: false, type: "module" %>
<%= csrf_meta_tags %>
<%= yield :head %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/search_layout.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%=
render_component_stylesheets
%>
<%= javascript_include_tag 'application', integrity: false %>
<%= javascript_include_tag 'application', integrity: false, type: "module" %>
<% if @content_item %>
<%= render 'govuk_publishing_components/components/meta_tags', content_item: @content_item.as_hash %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion features/step_definitions/filtering_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
end

When(/^I click the (.*) remove control$/) do |filter|
expect(page).to have_css(".js-enabled")
expect(page).to have_css(".govuk-frontend-supported")

button = page.find("span[class='facet-tag__text']", text: filter).sibling("button[data-module='remove-filter-link']")
button.click
Expand Down
2 changes: 1 addition & 1 deletion spec/javascripts/live_search_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ describe('liveSearch', function () {
})

it('should show the filter results button if the GOVUK.support.history returns false', function () {
// Hide the filter button (this is done in the CSS under the .js-enabled selector normally)
// Hide the filter button (this is done in the CSS under the .govuk-frontend-supported selector normally)
$form.find('.js-live-search-fallback').hide()
expect($form.find('.js-live-search-fallback').is(':visible')).toBe(false)
GOVUK.support.history = function () { return false }
Expand Down

0 comments on commit 47146d8

Please sign in to comment.