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

Element properties are undefined when rendering template #2121

Closed
mjgreen145 opened this issue Jul 20, 2015 · 2 comments
Closed

Element properties are undefined when rendering template #2121

mjgreen145 opened this issue Jul 20, 2015 · 2 comments

Comments

@mjgreen145
Copy link

Hey,

I having an issue trying to do something which seems like it should be simple.
When using a function to get a computed property, the property of the element is undefined.

See this JSBin: http://jsbin.com/dehiloqawo/edit?html,console,output

I have found that after rendering (where I am logging out the property, it exists. Also, if I wrap the div inside a dom-if template with a condition which is always true, then it renders correctly:

http://jsbin.com/jifiweyade/edit?html,console,output

I don't know whether I'm going about this the wrong way, or whether there is an issue with Polymer. It seems related to either #310 or #1500, but both of these seems to have been solved.

Any help greatly appreciated.

@kevinpschaaf
Copy link
Member

Computed properties only compute when their dependencies are set or change. Your _getDisplayName function has a dependency on this.name but didn't declare it as a dependency in its signature, and so it is not being re-computed when name is set. Declaring name in the function signature (e.g. _getDisplayName(name) tells Polymer to compute whenever name changes.

Working example:
http://jsbin.com/qipaja/edit?html,console,output

@mjgreen145
Copy link
Author

Thanks very much @kevinpschaaf

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

No branches or pull requests

2 participants