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

Bug: computed properties can fall out of sync with attributes #50

Closed
klebba opened this issue Jan 14, 2020 · 1 comment
Closed

Bug: computed properties can fall out of sync with attributes #50

klebba opened this issue Jan 14, 2020 · 1 comment
Assignees

Comments

@klebba
Copy link
Collaborator

klebba commented Jan 14, 2020

We have a property definition like this:

open: {
  type: Boolean,
  reflect: true,
  computed: 'computeOpen(model)',
  observer: 'observeOpen',
},

Then we have a demo page with plain HTML like this: <my-element open></my-element>open should be read only since it’s computed, but we have declared it in the markup accidentally due to a refactor. When I poll the instance of my-element for the value of it's open property the result is undefined which is correct.

The issue though is that the attribute is not removed when the element boots up. This causes a bug where styles which look for my-element[open] are being matched, but the inner template which is binding open to a child element is binding the value undefined

@theengineear
Copy link
Collaborator

The new version of x-element will throw an error like this:

Uncaught Error: Property "HelloElement.properties.open" is computed (computed properties are read-only).

I think that fixes your problem one way or another. I'll close this down, but feel free to reopen if you think it's not going to handle this case correctly.

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