@ministryofjustice/frontend 5.1.1 → 5.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/moj/all.bundle.js +23 -6
- package/moj/all.bundle.js.map +1 -1
- package/moj/all.bundle.mjs +23 -6
- package/moj/all.bundle.mjs.map +1 -1
- package/moj/common/moj-frontend-version.mjs +1 -1
- package/moj/components/add-another/add-another.bundle.js +22 -5
- package/moj/components/add-another/add-another.bundle.js.map +1 -1
- package/moj/components/add-another/add-another.bundle.mjs +22 -5
- package/moj/components/add-another/add-another.bundle.mjs.map +1 -1
- package/moj/components/add-another/add-another.mjs +22 -5
- package/moj/components/add-another/add-another.mjs.map +1 -1
- package/moj/core/_moj-frontend-properties.scss +1 -1
- package/moj/moj-frontend.min.css +1 -1
- package/moj/moj-frontend.min.js +1 -1
- package/moj/moj-frontend.min.js.map +1 -1
- package/package.json +2 -2
package/moj/all.bundle.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*
|
|
15
15
|
* {@link https://github.com/ministryofjustice/moj-frontend/releases}
|
|
16
16
|
*/
|
|
17
|
-
const version = '5.1.
|
|
17
|
+
const version = '5.1.3';
|
|
18
18
|
|
|
19
19
|
class AddAnother extends govukFrontend.Component {
|
|
20
20
|
/**
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
*/
|
|
91
91
|
updateAttributes($item, index) {
|
|
92
92
|
$item.querySelectorAll('[data-name]').forEach($input => {
|
|
93
|
-
if (!($input
|
|
93
|
+
if (!this.isValidInputElement($input)) {
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const name = $input.getAttribute('data-name') || '';
|
|
@@ -121,13 +121,23 @@
|
|
|
121
121
|
*/
|
|
122
122
|
resetItem($item) {
|
|
123
123
|
$item.querySelectorAll('[data-name], [data-id]').forEach($input => {
|
|
124
|
-
if (!($input
|
|
124
|
+
if (!this.isValidInputElement($input)) {
|
|
125
125
|
return;
|
|
126
126
|
}
|
|
127
|
-
if ($input
|
|
128
|
-
$input.
|
|
129
|
-
|
|
127
|
+
if ($input instanceof HTMLSelectElement) {
|
|
128
|
+
$input.selectedIndex = -1;
|
|
129
|
+
$input.value = '';
|
|
130
|
+
} else if ($input instanceof HTMLTextAreaElement) {
|
|
130
131
|
$input.value = '';
|
|
132
|
+
} else {
|
|
133
|
+
switch ($input.type) {
|
|
134
|
+
case 'checkbox':
|
|
135
|
+
case 'radio':
|
|
136
|
+
$input.checked = false;
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
$input.value = '';
|
|
140
|
+
}
|
|
131
141
|
}
|
|
132
142
|
});
|
|
133
143
|
}
|
|
@@ -157,6 +167,13 @@
|
|
|
157
167
|
}
|
|
158
168
|
}
|
|
159
169
|
|
|
170
|
+
/**
|
|
171
|
+
* @param {Element} $input - the input to validate
|
|
172
|
+
*/
|
|
173
|
+
isValidInputElement($input) {
|
|
174
|
+
return $input instanceof HTMLInputElement || $input instanceof HTMLSelectElement || $input instanceof HTMLTextAreaElement;
|
|
175
|
+
}
|
|
176
|
+
|
|
160
177
|
/**
|
|
161
178
|
* Name for the component used when initialising using data-module attributes.
|
|
162
179
|
*/
|