diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ec7b2ccd7..4f71f90ded 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ govukInput({ ### Fixes - [Pull request #1512: Update components to only output items when they are defined](https://github.com/alphagov/govuk-frontend/pull/1512). +- [Pull request #1538: Simplify button types to avoid unnecessary type attribute](https://github.com/alphagov/govuk-frontend/pull/1538). ## 3.0.0 (Breaking release) diff --git a/src/govuk/components/button/template.njk b/src/govuk/components/button/template.njk index 26d21fc81c..613489a25d 100644 --- a/src/govuk/components/button/template.njk +++ b/src/govuk/components/button/template.njk @@ -37,7 +37,7 @@ treat it as an interactive element - without this it will be {#- Define common attributes we can use for both button and input types #} -{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %} type="{{ params.type if params.type else 'submit' }}"{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} +{%- set buttonAttributes %}{% if params.name %} name="{{ params.name }}"{% endif %}{% if params.disabled %} disabled="disabled" aria-disabled="true"{% endif %}{% if params.preventDoubleClick %} data-prevent-double-click="true"{% endif %}{% endset %} {#- Actually create a button... or a link! #} @@ -49,12 +49,12 @@ treat it as an interactive element - without this it will be {%- elseif element == 'button' %} - {%- elseif element == 'input' %} - + {%- endif %} diff --git a/src/govuk/components/button/template.test.js b/src/govuk/components/button/template.test.js index 41b813dfbe..4081929e41 100644 --- a/src/govuk/components/button/template.test.js +++ b/src/govuk/components/button/template.test.js @@ -256,7 +256,6 @@ describe('Button', () => { const $component = $('.govuk-button') expect($component.get(0).tagName).toEqual('button') - expect($component.attr('type')).toEqual('submit') }) })