Skip to content

Commit 2de0cbf

Browse files
committed
Rebuild dist file
1 parent d96d82f commit 2de0cbf

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

src/LiveComponent/assets/dist/live_controller.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -990,27 +990,28 @@ function cloneHTMLElement(element) {
990990
return newElement;
991991
}
992992

993-
function getArrayValue(element, value, currentValue) {
994-
if (!(currentValue instanceof Array)) {
995-
currentValue = [];
993+
function updateArrayDataFromChangedElement(element, value, currentValues) {
994+
if (!(currentValues instanceof Array)) {
995+
currentValues = [];
996996
}
997997
if (element instanceof HTMLInputElement && element.type === 'checkbox') {
998-
const index = currentValue.indexOf(value);
998+
const index = currentValues.indexOf(value);
999999
if (element.checked) {
10001000
if (index === -1) {
1001-
currentValue.push(value);
1001+
currentValues.push(value);
10021002
}
1003+
return currentValues;
10031004
}
1004-
else {
1005-
if (index > -1) {
1006-
currentValue.splice(index, 1);
1007-
}
1005+
if (index > -1) {
1006+
currentValues.splice(index, 1);
10081007
}
1008+
return currentValues;
10091009
}
1010-
else if (element instanceof HTMLSelectElement) {
1011-
currentValue = Array.from(element.selectedOptions).map(el => el.value);
1010+
if (element instanceof HTMLSelectElement) {
1011+
currentValues = Array.from(element.selectedOptions).map(el => el.value);
1012+
return currentValues;
10121013
}
1013-
return currentValue;
1014+
throw new Error(`The element used to determine array data from is unsupported (${element.tagName} provided)`);
10141015
}
10151016

10161017
const DEFAULT_DEBOUNCE = 150;
@@ -1123,7 +1124,7 @@ class default_1 extends Controller {
11231124
if (/\[]$/.test(model)) {
11241125
const { currentLevelData, finalKey } = parseDeepData(this.dataValue, normalizeModelName(model));
11251126
const currentValue = currentLevelData[finalKey];
1126-
value = getArrayValue(element, value, currentValue);
1127+
value = updateArrayDataFromChangedElement(element, value, currentValue);
11271128
}
11281129
else if (element instanceof HTMLInputElement
11291130
&& element.type === 'checkbox'

0 commit comments

Comments
 (0)