dfilatov / vidom

Library to build UI based on virtual DOM
MIT License
415 stars 16 forks source link

issues with textarea, buttons, checkbox and radio #92

Closed ghost closed 9 years ago

ghost commented 9 years ago

A textarea's value should be set as an HTML attribue not a property. Else it will not accept numbers, and you can't cast to string either.

var node = createNode("textarea").attrs({ value: 123 }).renderToDom();

Not fully tested, but seems to be same issues with: buttons, checkbox and radio

Have a look here too see different edge cases:
https://github.com/ractivejs/ractive/tree/dev/src/virtualdom/items/Element/Attribute/prototype/update

dfilatov commented 9 years ago

I've tried this:

vidom.mountToDom(
    document.body,
    createNode('textarea').attrs({ value : 123 }));

And have seen this: screen shot 2015-08-07 at 16 28 18

What's wrong?

dfilatov commented 9 years ago

@rickardjanson ?

ghost commented 9 years ago

@dfilatov Sorry. Not home at the moment. Issue occur in Internet Explorer. Older versions. In a few edge cases you have to set it as an attribue value. When I mention that, there are also an issue with type attribute in IE. I will see later if I can find some references, but for now I suggest have a look in the jQuery source code for valHooks.

updated With webkit browsers there are sometimes an issue too, not sure if fixed in v. 44. I have to check the forums for that to verify.

ghost commented 9 years ago

@dfilatov This is not my computer, but to answer you better. I just remember how we did it before with Internet Exolorer 10. We did'nt cast to string, but used .toString() to force it to be a string and then set as a property.

ghost commented 9 years ago

Here is a few other issues I remember now:

dfilatov commented 9 years ago

I've tried in IE9:

vidom.mountToDom(
    document.body,
    createNode('textarea').attrs({ value : 123 }));

And everything has worked as expected so I'm closing this issue. If you have certain non-working cases please create separate issues. But please check before whether your case doesn't work.