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

Allow empty template results? #168

Closed
43081j opened this issue Aug 31, 2018 · 2 comments · Fixed by #712
Closed

Allow empty template results? #168

43081j opened this issue Aug 31, 2018 · 2 comments · Fixed by #712

Comments

@43081j
Copy link
Contributor

43081j commented Aug 31, 2018

Currently moving over to lit straight from polymer 2, we commonly have:

if (!this.prop) {
  return html``;
}
return html`some content`;

Is it worth us allowing a null return type in render so we can have an empty template?

and inside lit, keep an emptyTemplate constant which is re-used (if needed)?

so we can have render(): TemplateResult|null?

edit:

having thought again about this, in reality it is probably less efficient to have null checks in the core. i guess the only solution to this would be to have an EmptyTemplate constant which is an already new'd up template result.

cc @justinfagnani

@abraham
Copy link
Contributor

abraham commented Aug 31, 2018

There is some related conversation on lit/lit#422

@markcellus
Copy link

Does returning this.prop in _shouldRender() (if using earlier versions) or shouldUpdate() work for you?

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

Successfully merging a pull request may close this issue.

4 participants