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

Property value incorrectly if using both of static properties() and @property decorator #890

Closed
5 tasks done
gogermany opened this issue Feb 4, 2020 · 2 comments
Closed
5 tasks done
Assignees

Comments

@gogermany
Copy link

Description

Lit-Element handle properties value incorrectly if using both of static properties() and @property decorator for create element extends from abstract class.

I think this problem is related with

  • abstract class no need to use @CustomElement
  • use static properties() in abstract class
  • use @property in child class

Live Demo

https://stackblitz.com/edit/lit-element-properties-problem?file=my-element.ts

Steps to Reproduce by using TypeScript

  1. Create abstract class BaseElement
// not define element @customElement because this is abstract class
abstract class BaseElement extends LitElement {

  public foo = false;
  
  // (I don't use  @property because I have to import properties from share properties)
  static get properties() {
    return { 
      foo: { type: Boolean, reflect: true }
    };
  }

  render(){
    return html`<p>${this.foo}</p>`;
  }
}
  1. Create MyElement
@customElement('my-element')
export class MyElement extends BaseElement {
  /**
   * Create new property with @property
   * Using this make a problem with static properties().
   * Remove this property and reload by click refresh button to get correct value
   */
  @property() bar = 'bar';
}
  1. Use element and set foo attribute is true
<my-element foo></my-element>

Expected Results

foo property value and element render should be true

Actual Results

foo property value and element render is false

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • Safari 13
  • IE 11

Versions

  • lit-element: v2.2.1
  • webcomponents: v2.4.1
@gregorymachon
Copy link

+1

@sorvell sorvell self-assigned this Feb 6, 2020
sorvell pushed a commit to lit/lit that referenced this issue Sep 2, 2020
@kevinpschaaf
Copy link
Member

Status: This has been fixed in the lit-next branch, but is still an open bug on master (lit-element 2.x).

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

No branches or pull requests

5 participants