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

<textarea> welcomes user with 'undefined' text value (only for object subproperties) #4630

Closed
6 tasks done
slawomir-brzezinski-at-interxion opened this issue May 25, 2017 · 5 comments
Assignees
Labels

Comments

@slawomir-brzezinski-at-interxion
Copy link

slawomir-brzezinski-at-interxion commented May 25, 2017

Description

An undefined value, when binding to <textarea>, is treated as 'undefined' text, but only if it appears in an object subproperty.
Interestingly null gets treated just fine. undefined in a flat property is also just fine.
<input type="text"> doesn't have the issue.
See the live demo.

Live Demo

http://jsbin.com/xukejamegi/edit?html,output

Expected Results

It should work like <input type="text">

Actual Results

The user value is an 'undefined' text.

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 9
  • Safari 8
  • IE 11

Versions

  • Polymer: v1.9.1, v2.0.0 (we are using 1.9.1 - please do try to fix 1.X)
  • webcomponents: 0.7.24
@TimvdLippe
Copy link
Contributor

For native HTML elements, you should use value$ for bindings instead of value: https://www.polymer-project.org/2.0/docs/devguide/data-binding#anatomy-of-a-data-binding

@slawomir-brzezinski-at-interxion
Copy link
Author

slawomir-brzezinski-at-interxion commented May 25, 2017

@TimvdLippe Using $value can't work with <textarea> because there isn't such an attribute.

If this was static HTML, you'd pass the value <textarea>here</textarea> but this doesn't work with two-way binding.
Rather, there exists a value property and binding to it is the Polymer prescribed pattern

@TimvdLippe
Copy link
Contributor

@slawomir-brzezinski-at-interxion Oh sorry I missed that. Yeah seems like a bug.

@kevinpschaaf
Copy link
Member

Thanks for the issue. Interesting that it's the first bug report we've had of this, even though Polymer 1.0 would have suffered from the same issue.

At any rate, we avoid this for <input>.value only because there's an explicit special-case check for that exact case in the binding code: https://github.com/Polymer/polymer/blob/master/lib/mixins/property-effects.html#L601

Since we've already got precedent for special-casing input, I think we'd just add an || node.localName == textarea' to the condition and fix the bug.

@slawomir-brzezinski-at-interxion
Copy link
Author

Thanks for fixing this guys.
@azakus does this fix 1.X at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants