diff --git a/CHANGELOG.md b/CHANGELOG.md index 0117701b..9fa8aaff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed + +- `replaceCustomValues()` only replacing element submission data that is a string + ## [0.2.4] - 2021-11-15 ### Fixed diff --git a/src/replaceCustomValues.ts b/src/replaceCustomValues.ts index 5f3c907e..c919e260 100644 --- a/src/replaceCustomValues.ts +++ b/src/replaceCustomValues.ts @@ -81,7 +81,7 @@ export function getElementSubmissionValue({ formatTime: (value: string) => string formatNumber: (value: number) => string formatCurrency: (value: number) => string -}): string | undefined | Array { +}): unknown { const formElement = findFormElement( form.elements, (element) => @@ -212,7 +212,10 @@ function replaceElementValues( formatCurrency, }) - return newString.replace(match, typeof value === 'string' ? value : '') + return newString.replace( + match, + value === undefined ? '' : (value as string), + ) }, text) }