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

Binding undefined object sub-properties may result in multi-prop observers not running #1877

Closed
kevinpschaaf opened this issue Jun 15, 2015 · 5 comments
Assignees

Comments

@kevinpschaaf
Copy link
Member

Binding structured data with undefined sub-properties into an element results in undefined being set to the property in question; typically we only expect undefined values transiently at startup, since they should either become valued by attributes in markup, bindings from above, or default values, and Polymer avoids calling multi-property observers until all dependencies become valued.

However, in the case of bindings to structured data, if a new object is set with undefined properties, this results in the element receiving undefined at runtime and may not properly react to this change in state.

See http://jsbin.com/cejusi/edit?html,output for repro, where dom-if receives undefined but since its observer is multi-prop, it waits until it becomes defined.

One idea is to explicitly trap the case that undefined is being set to a Polymer element property and convert that to the element's default value for the property, if it exists.

@robrez
Copy link

robrez commented Jun 15, 2015

I reported some problems w/ a multi-property attribute binding earlier, #1874, it sounds like what kevin's describing:

Polymer avoids calling multi-property observers until all dependencies become valued

@kevinpschaaf
Copy link
Member Author

Issue for proposed fix here: #1946 with PR in #1941

@sorvell
Copy link
Contributor

sorvell commented Sep 2, 2015

Alternatively object sub-properties could be treated as null. This would indicate a value has been set causing observers to fire without requiring a default value to be set.

@tjsavage tjsavage added the 1.x label Sep 8, 2016
@stale
Copy link

stale bot commented Mar 13, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Mar 13, 2020
@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

@stale stale bot closed this as completed Apr 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants