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

Introduce Lit Element #1738

Merged
merged 1 commit into from
Oct 7, 2018
Merged

Introduce Lit Element #1738

merged 1 commit into from
Oct 7, 2018

Conversation

balloob
Copy link
Member

@balloob balloob commented Oct 5, 2018

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.

@ghost ghost assigned balloob Oct 5, 2018
@ghost ghost added the in progress label Oct 5, 2018
<ha-progress-button id="progress" progress="[[progress]]" on-click="buttonTapped" disabled="[[disabled]]"><slot></slot></ha-progress-button>
`;
<ha-progress-button
.progress="${this.progress}"
Copy link
Member Author

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()}"
Copy link
Member Author

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}"
Copy link
Member Author

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)`)

@balloob balloob force-pushed the lit-element branch 2 times, most recently from 188ed9a to 8ed954d Compare October 5, 2018 13:39
`;
<ha-progress-button
.progress="${this.progress}"
@click="${this._buttonTapped}"
Copy link
Member Author

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()))

@balloob
Copy link
Member Author

balloob commented Oct 5, 2018

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: { },
Copy link
Member

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?

Copy link
Member Author

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

@balloob balloob merged commit 1b70b6e into master Oct 7, 2018
@balloob balloob deleted the lit-element branch October 7, 2018 09:07
@ghost ghost removed the in progress label Oct 7, 2018
zsarnett pushed a commit to zsarnett/home-assistant-polymer that referenced this pull request Oct 13, 2018
zsarnett pushed a commit to zsarnett/home-assistant-polymer that referenced this pull request Oct 13, 2018
zsarnett pushed a commit to zsarnett/home-assistant-polymer that referenced this pull request Oct 14, 2018
@github-actions github-actions bot locked and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants