Skip to content

Odd behaviour when setting value property of inputs? #2

Closed
@arjaneising

Description

Hi,

While using your simple-virtual-dom package, I stumbled upon a case when setting the value of inputs such as input and textarea.

Code:

el('input', { 'id': 'command', value: 'default' }, null);
// you start typing into the input
// .. then, after a while :
el('input', { 'id': 'command', value: state.command }, null)

Expected result: input#command has a value with contents of variable state.command.
Actual result: it still has the input you typed into the input element

If the value is changed in the meantime, this won't work, as the HTML value property, as set by setAttribute, is a "default" value.

It could be that this behaviour could be altered to work in these cases, I am not sure if it should. A fix would involve a hardcoded check for value as property name, setting it with .value = x instead of .setAttribute('value', x), and a way to make sure the diff still works as it should.

Thanks, if you need any help with this, let me know! :-)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions