Skip to content

Instantly share code, notes, and snippets.

@yuretz
Last active August 24, 2019 16:43
Show Gist options
  • Save yuretz/d721a0ff8ef5083d7d3d4ac2aa74fc42 to your computer and use it in GitHub Desktop.
Save yuretz/d721a0ff8ef5083d7d3d4ac2aa74fc42 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title>
Lighterhtml blur test
</title>
<script src="https://unpkg.com/lodash"></script>
<script src="https://unpkg.com/lighterhtml"></script>
</head>
<body>
<script>
const {html, render} = lighterhtml;
const blur = () => {
console.log('blur');
update();
}
const view = (state = false) => () => html`
<div>
Steps to reproduce:
<ol>
<li>Open console</li>
<li>Click on the input below and type swomething there</li>
<li>Without clicking anywhere else, click the browser address line and type <code>#foo</code> in the end of current address</li>
<li>Hit &quot;Enter&quot;</li>
</ol>
</div>
<div>
${state ? html`<div><p>Mojn</p></div>` : html`<div><p>Test</p><input type="text" value=${state} onblur=${blur}></div>`}
</div>
`;
const update = (state) => render(document.body, view(state));
const lateUpdate = _.debounce(update);
window.addEventListener('popstate', () => {
console.log('popstate');
lateUpdate(true);
});
update();
</script>
</body>
<html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment