1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #12247 from timvandermeij/acroform-choice-null

Improve the field value parsing for choice widgets to handle `null` values
This commit is contained in:
Tim van der Meij 2020-08-21 23:17:20 +02:00 committed by GitHub
commit 3c790936c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 43 deletions

View file

@ -1610,11 +1610,14 @@ class ChoiceWidgetAnnotation extends WidgetAnnotation {
}
}
// Determine the field value. In this case, it may be a string or an
// array of strings. For convenience in the display layer, convert the
// string to an array of one string as well.
if (!Array.isArray(this.data.fieldValue)) {
// The field value can be `null` if no item is selected, a string if one
// item is selected or an array of strings if multiple items are selected.
// For consistency in the API and convenience in the display layer, we
// always make the field value an array with zero, one or multiple items.
if (isString(this.data.fieldValue)) {
this.data.fieldValue = [this.data.fieldValue];
} else if (!this.data.fieldValue) {
this.data.fieldValue = [];
}
// Process field flags for the display layer.