Skip to content

Input modifiers #3937

Closed
Closed
@Rich-Harris

Description

@Rich-Harris

#3527 (comment)

Is your feature request related to a problem? Please describe.
Date inputs have string bindings, which are rarely helpful.

Describe the solution you'd like
It should be possible to specify the type of binding:

<input type="date" bind:value|date={date_as_date}>
<input type="date" bind:value|number={date_as_number}>
<input type="date" bind:value|string={date_as_string}>

In v4, we can switch the default over to the value|date behaviour.

Describe alternatives you've considered
Adding valueAsNumber and valueAsDate bindings. There are a couple of reasons not to do this:

  • It would introduce an inconsistency with how number and range inputs are currently handled
  • Resolving that inconsistency would mean expecting people to type valueAsNumber instead of just value. It's unergonomic
  • Having multiple binding options makes it easy for someone to use them all simultaneously, which could lead to subtle bugs from not having a single source of truth

How important is this feature to you?
Medium

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions