Skip to content

Instantly share code, notes, and snippets.

@ilyagr
Last active February 17, 2020 08:54
Show Gist options
  • Save ilyagr/a035c3c7abb3389593ed7ccd51844568 to your computer and use it in GitHub Desktop.
Save ilyagr/a035c3c7abb3389593ed7ccd51844568 to your computer and use it in GitHub Desktop.
// source https://jsbin.com
<html><body><script type="module">
import { html, render } from "https://unpkg.com/lit-html@1.1.0?module";
function _selector(values) {
return html`
<select>
<option value="">Choose one:</option>
${values.map(
k =>
html`
<option>${k}</option>
`
)}
</select>
`;
}
// 2 => 6 => 7 => 3
class MyWidgetBug {
constructor() {
this.state = false;
}
refresh() {
render([html`
<input
type="checkbox"
@change=${e => {
this.state = e.target.checked;
this.refresh();
}}
>`,
this.state ? _selector([1, 2, 3])
: _selector([5, 6, 7])
],
document.body
);
}
}
new MyWidgetBug().refresh();
</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment