@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.mjs
CHANGED
|
@@ -312,7 +312,7 @@ function createAll(Component, config, createAllOptions) {
|
|
|
312
312
|
*
|
|
313
313
|
* {@link https://github.com/ministryofjustice/moj-frontend/releases}
|
|
314
314
|
*/
|
|
315
|
-
const version = '5.1.
|
|
315
|
+
const version = '5.1.3';
|
|
316
316
|
|
|
317
317
|
class AddAnother extends Component {
|
|
318
318
|
/**
|
|
@@ -388,7 +388,7 @@ class AddAnother extends Component {
|
|
|
388
388
|
*/
|
|
389
389
|
updateAttributes($item, index) {
|
|
390
390
|
$item.querySelectorAll('[data-name]').forEach($input => {
|
|
391
|
-
if (!($input
|
|
391
|
+
if (!this.isValidInputElement($input)) {
|
|
392
392
|
return;
|
|
393
393
|
}
|
|
394
394
|
const name = $input.getAttribute('data-name') || '';
|
|
@@ -419,13 +419,23 @@ class AddAnother extends Component {
|
|
|
419
419
|
*/
|
|
420
420
|
resetItem($item) {
|
|
421
421
|
$item.querySelectorAll('[data-name], [data-id]').forEach($input => {
|
|
422
|
-
if (!($input
|
|
422
|
+
if (!this.isValidInputElement($input)) {
|
|
423
423
|
return;
|
|
424
424
|
}
|
|
425
|
-
if ($input
|
|
426
|
-
$input.
|
|
427
|
-
|
|
425
|
+
if ($input instanceof HTMLSelectElement) {
|
|
426
|
+
$input.selectedIndex = -1;
|
|
427
|
+
$input.value = '';
|
|
428
|
+
} else if ($input instanceof HTMLTextAreaElement) {
|
|
428
429
|
$input.value = '';
|
|
430
|
+
} else {
|
|
431
|
+
switch ($input.type) {
|
|
432
|
+
case 'checkbox':
|
|
433
|
+
case 'radio':
|
|
434
|
+
$input.checked = false;
|
|
435
|
+
break;
|
|
436
|
+
default:
|
|
437
|
+
$input.value = '';
|
|
438
|
+
}
|
|
429
439
|
}
|
|
430
440
|
});
|
|
431
441
|
}
|
|
@@ -455,6 +465,13 @@ class AddAnother extends Component {
|
|
|
455
465
|
}
|
|
456
466
|
}
|
|
457
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @param {Element} $input - the input to validate
|
|
470
|
+
*/
|
|
471
|
+
isValidInputElement($input) {
|
|
472
|
+
return $input instanceof HTMLInputElement || $input instanceof HTMLSelectElement || $input instanceof HTMLTextAreaElement;
|
|
473
|
+
}
|
|
474
|
+
|
|
458
475
|
/**
|
|
459
476
|
* Name for the component used when initialising using data-module attributes.
|
|
460
477
|
*/
|