Skip to content

[0.6.0-dev.6] Class property doesn't update value in template/markup #174

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

Closed
aadamsx opened this issue Sep 7, 2018 · 3 comments
Closed

Comments

@aadamsx
Copy link

aadamsx commented Sep 7, 2018

I'm using lit-element 0.6.0-dev.6/webcomponentsjs 2.1.1 and ran into an issue that might be a bug.

Basically the value in the LitElement class increments/decrements (you can see from the console logging), but the this.value property on the class doesn't display the change in markup.

To make things easier, I built a repo to reproduce the issue: https://github.com/aadamsx/meteor-lithtml

@sorvell
Copy link
Member

sorvell commented Sep 11, 2018

Initializing values in the property options (like this) is not supported.

This can be done via a class field (if/when supported) or in the constructor. Here's a working example: http://jsbin.com/seweyoy/edit?html,output

@sorvell sorvell closed this as completed Sep 11, 2018
@aadamsx
Copy link
Author

aadamsx commented Sep 11, 2018

Oh, wow! Thank you for helping me with code examples! 👍

I got the initializing of values in the property options from this post: https://coryrylan.com/blog/building-web-components-with-lit-html

Look under the heading "Properties, Attributes and Decorators" at the XCounter class.

He's actually using decorators their, but since I'm using Babel7 I decided to use his (commented out) static get properties example instead. Looks like until Bable7 when decorators are supported, I'll be doing my init in the constructors.

Thanks again!

@coryrylan
Copy link

I updated the post and code example to use the static property list by default to prevent further confusion :)

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

3 participants