-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Introduce Lit Element #1738
Introduce Lit Element #1738
Conversation
<ha-progress-button id="progress" progress="[[progress]]" on-click="buttonTapped" disabled="[[disabled]]"><slot></slot></ha-progress-button> | ||
`; | ||
<ha-progress-button | ||
.progress="${this.progress}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sets a property on the DOM element (in JS: el.progress = this.progress
)
`; | ||
<ha-progress-button | ||
.progress="${this.progress}" | ||
@click="${() => this.buttonTapped()}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listen to events on this component (in JS: el.addEventListener('click', () => this.buttonTapped())
)
<ha-progress-button | ||
.progress="${this.progress}" | ||
@click="${() => this.buttonTapped()}" | ||
?disabled="${this.disabled}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Toggle a boolean based attribute (in JS: el.toggleAttribute('disabled', this.disabled)`)
188ed9a
to
8ed954d
Compare
`; | ||
<ha-progress-button | ||
.progress="${this.progress}" | ||
@click="${this._buttonTapped}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listen to events on this component (in JS: el.addEventListener('click', () => this.buttonTapped())
)
I've removed the usage of eslint-plugin-lit because it was unable to distinguish between Polymer 3 and Lit Element templates, resulting in false positives (example). Raised an issue |
value: false, | ||
}, | ||
|
||
hass: { }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why empty object here? Why not hass: Object
? Is there a difference?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Using a function will be used to serialize values when set as attributes. We don't want it to be serialized. See type
: https://github.com/Polymer/lit-element#a-simple-base-class-for-creating-custom-elements-rendered-with-lit-html
Lit Element is the new base class from the Polymer team. It uses lit-html instead of the Polymer templating engine. Lit-html is faster and leaner.
This introduces lit-element and converts a component as an example. The class definition is very similar to Polymer.