Skip to content

Commit

Permalink
Merge pull request #10 from oneblink/ON-16925
Browse files Browse the repository at this point in the history
ON-16925 # Fixed replaceCustomValues only replacing element submissio…
  • Loading branch information
Zaxist authored Nov 18, 2021
2 parents e54be00 + f866560 commit 8c0632e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions src/replaceCustomValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function getElementSubmissionValue({
formatTime: (value: string) => string
formatNumber: (value: number) => string
formatCurrency: (value: number) => string
}): string | undefined | Array<string> {
}): unknown {
const formElement = findFormElement(
form.elements,
(element) =>
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 8c0632e

Please sign in to comment.