Last active
August 24, 2019 16:43
-
-
Save yuretz/d721a0ff8ef5083d7d3d4ac2aa74fc42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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 "Enter"</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