Skip to content

[quirk] UIAlert stringifies value #1424

@KernelDeimos

Description

@KernelDeimos

The following code would not work as intended:

const answer = await UIAlert({
    message: `Press "yes" to perform dangerous action!`,
    buttons: [
        {
            label: i18n('yes'),
            value: true,
        },
        {
            label: i18n('no'),
            value: false,
        },
    ]
});
if ( answer ) do_dangerous_action();

Regardless of which button the user presses, do_dangerous_action() is called. This is because value is stringified unnecessarily. Instead of the value false, we get the value "false", which is truthy.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions