Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formatting fails for messages with select statement if selected field has value constructor #4490

Closed
ksenkso opened this issue Aug 14, 2024 · 1 comment

Comments

@ksenkso
Copy link

ksenkso commented Aug 14, 2024

Which package?

intl-messageformat

Describe the bug

With a message containing a select clause, when a IntlMessageFormat#format is called with values object that contains a string constructor as the value of the field on which the selection is done, it throws a error like this:

TypeError: Cannot read properties of undefined (reading 'length')
    at formatToParts (/path/to/project/node_modules/intl-messageformat/src/formatters.js:40:13)
    at formatToParts (/path/to/project/node_modules/intl-messageformat/src/formatters.js:165:39)

To Reproduce

Codesandbox URL

https://codesandbox.io/p/sandbox/intl-messageformat-constructor-bug-y37dvk

Reproducible Steps/Repo

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/p/sandbox/intl-messageformat-constructor-bug-y37dvk
  2. See the alert pop up with the error message

Expected behavior

The string constructor is alerted.

Screenshots

None

Desktop (please complete the following information):

  • OS: Ubuntu 24.04
  • Browser: chrome
  • Version: 126

Smartphone (please complete the following information):

Didn't test but doesn't really matter.

Additional context

No additional context, but on how to resolve this issue: I think it should be ok to just use Object.create(null) for objects that hold user-provided keys, but maybe maps can be used too.

@ksenkso ksenkso added the bug label Aug 14, 2024
Copy link

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Sep 14, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant