-
Notifications
You must be signed in to change notification settings - Fork 318
Closed
Labels
Description
Description
When using the default TypeScript settings in create-react-app
it seems that the @property
decorator isn't creating the accessors correctly. Strangle running a delete (delete this.text
) on the property fixes the accessors.
Workaround
To get the accessors working for the moment just run a delete on the property you created in the constructor.
@customElement("my-element")
export class MyElement extends LitElement {
@property() text: string;
constructor() {
super();
delete this["text"]; // This will fix the accessors.
this.text = "Initial text.";
}
render(): TemplateResult {
return html`<p>${this.text}</p>`;
}
}
Demo
https://github.com/karlbennett/litelement-property-bug
Steps to Reproduce
Example:
- Create
my-element
- Add a
text
property tomy-element
with the@property
decorator. - Use the
my-element
tag in some HTML. - Select the
my-element
tag instance. - Assign a new value to the
text
property (myElement.text = 'some new text.';
).
Expected Results
A property update should trigger update events/methods (update
, updated
);
Actual Results
The events/methods are not triggered on a property update.
Browsers Affected
- Chrome
- Firefox
- Edge
- Safari 11
- Safari 10
- IE 11
Versions
- lit-element: 2.2.1
uqee and nikitalpopovuqee