* filterValues takes an object containing form input values * and returns a new object that only contains keys that are * specified by the closest "hx-params" attribute * @param {FormData} inputValues * @param {Element} elt * @returns {FormData}
(inputValues, elt)
| 3513 | * @returns {FormData} |
| 3514 | */ |
| 3515 | function filterValues(inputValues, elt) { |
| 3516 | const paramsValue = getClosestAttributeValue(elt, 'hx-params') |
| 3517 | if (paramsValue) { |
| 3518 | if (paramsValue === 'none') { |
| 3519 | return new FormData() |
| 3520 | } else if (paramsValue === '*') { |
| 3521 | return inputValues |
| 3522 | } else if (paramsValue.indexOf('not ') === 0) { |
| 3523 | forEach(paramsValue.substr(4).split(','), function(name) { |
| 3524 | name = name.trim() |
| 3525 | inputValues.delete(name) |
| 3526 | }) |
| 3527 | return inputValues |
| 3528 | } else { |
| 3529 | const newValues = new FormData() |
| 3530 | forEach(paramsValue.split(','), function(name) { |
| 3531 | name = name.trim() |
| 3532 | if (inputValues.has(name)) { |
| 3533 | inputValues.getAll(name).forEach(function(value) { newValues.append(name, value) }) |
| 3534 | } |
| 3535 | }) |
| 3536 | return newValues |
| 3537 | } |
| 3538 | } else { |
| 3539 | return inputValues |
| 3540 | } |
| 3541 | } |
| 3542 | |
| 3543 | /** |
| 3544 | * @param {Element} elt |
no test coverage detected
searching dependent graphs…