Given a web component extending LitElement:
import { html, LitElement } from 'lit';
import { customElement } from 'lit/decorators.js';
@customElement('my-element')
export class MyElement extends LitElement {
render() {
return html`
<div>some static content</div>
<div class="slotted"><slot></slot></div>
<div>more static content</div>
`;
}
}
And the component is used like this:
<my-element>${maybeContentMaybeNothing}</my-element>
Since maybeContentMaybeNothing
could contain html or text or nothing at all, how can the div.slotted
element be hidden if maybeContentMaybeNothing
contains nothing, but shown if it contains anything?